How to add new state to the Redux store?
See original GitHub issueI am new to this project, and I am enjoying reading the code. But I am having a hard time figuring out how to add my app’s (new) state to the store.
The specifics of my app is that my server.js code will receive data asynchronously from some other server, which needs to be reflected in the GUI.
My understanding of the Redux pattern is that my server code should create actions for each newly-arrived bit of information and then dispatch them to the store. The update in the store then propagates to the React containers/components that rely on it.
I realize that this might be more of a Redux question, but I would love to see an outline of steps for the following in react-redux-universal-hot-example:
- Extending the ‘schema’ of the store with a new kind of information. (I’m not sure how to ensure that my new state data won’t conflict with existing info in the store);
- Creating actions (I think that’s straightforward - simply make a new object with
{ type: xxx, ... }
) - Hooking those actions into the dispatch() method. (I see the @asyncConnect() and @ connect() methods, but don’t entirely understand what they do.)
- and whatever else needs to happen…
Thanks!
Issue Analytics
- State:
- Created 7 years ago
- Comments:8
Top Results From Across the Web
Redux Fundamentals, Part 3: State, Actions, and Reducers
The official Redux Fundamentals tutorial: learn how reducers update state in response to actions.
Read more >How To Manage State in React with Redux - DigitalOcean
Step 1 — Setting Up a Store · Step 2 — Creating Actions and Reducers · Step 3 — Dispatching Changes in a...
Read more >Managing your React state with Redux - Medium
reducer - A reducing function. We will describe it below. · initialState - The initial state of the store. · enhancer - Can...
Read more >How do I add an element to array in reducer of React native ...
Two different options to add item to an array without mutation case ADD_ITEM : return { ...state, arr: [...state.arr, action.newItem] }.
Read more >Actions and reducers: updating state - Human Redux
Redux reducer rule #2: If you change it, replace it. ; // this is just creating another reference // to the same object...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Add new state is simple! Just write your own state file under
redux/modules/
, here is part of mineschedule.js
:@richb-hanover
@tearsofphoenix Your suggestion worked perfectly for me as well. That kind of answer really rocks 🤘