Allow async redux initial state
See original GitHub issueright now redux initial state can be set by export const reduxInitialState
but I have a request to fulfil where redux initial state can be decided after an Ajax request only. Is there a way to do it?
if not I would rather suggest following solution:
export const reduxInitialState = async() => {
const data = await someAsyncFunction();
return {
some: "staticData",
dynamic: data
};
}
And where ever the function is utilised it can be awaited!
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Async initial state React-Redux Redux-Thunk - Stack Overflow
In my reducer I have a load method: function updateReducer(state, action) { switch (action. type) { case 'load': return action.
Read more >Redux Fundamentals, Part 6: Async Logic and Data Fetching
It only knows how to synchronously dispatch actions, update the state by calling the root reducer function, and notify the UI that something ......
Read more >redux-async-initial-state - npm
It is simple redux middleware that helps you load redux initial state asynchronously. Latest version: 0.3.0, last published: 5 years ago.
Read more >Async actions in bare Redux with Thunk or custom middleware
Learn how to manage asynchronous actions in React apps with Redux ... Let's define the initial state of our application and the reducer...
Read more >KELiON/redux-async-initial-state - GitHub
With redux it is quite simple to synchronously load initial state, i.e. from localStorage: ... const initialState = JSON.parse ...
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
@MikeShobe the release date is targeted for version 2 is end of June.
hello,
You can use Redux-Thunk in client.js like this: