score:2
as i said in comments: you should make it as empty array/object and "initialize" state later with proper action. right now instead of making state with array you fill it with promise.
my sample using react with hooks and settimeout
(this will work the same with your fetch): https://codesandbox.io/s/6wwy4xxwwr?fontsize=14
you can also just do it in your "index.js
" using store.dispatch(action)
like:
import store from './filewithconststore';
fetch()
.then(data => {
store.dispatch({
type: 'init_bookings',
payload: data
})
});
but this rather quick than approved solution.
Source: stackoverflow.com
Related Query
- How to load axios data as initial redux state
- How to load initial data from rails to redux
- How to Assign react redux state api get data using axios
- How to push the data from api to my initial state list items using the redux toolkit?
- How to set an initial state with hooks when data finish to load
- how to get axios.get data and where to put it in redux reducer initial state
- How assign data to redux initial state array
- how to set initial state in redux
- How to persist redux state data in Next.js?
- How to dispatch an redux action to load data inside useEffect on page load
- (Universal React + redux + react-router) How to avoid re-fetching route data on initial browser load?
- how can we use redux state in useState to set initial values
- How to generate a unique id automatically for the data that is posted to an API server using axios library in redux
- Should a Redux state tree represent how data is organized in the UI?
- How to reset the state to it's initial state in redux store?
- React redux setting initial state from axios call
- How to post data to an API server using axios library in redux
- How to load initial data in Flux, but only if a component needs it
- How do I set initial state to data fetched with useQuery?
- How do i pull data from redux state in react
- How to add data to redux state array without any id in a reducer?
- How can I watch for state of data in redux container, when I want to sort or filter it?
- How to set a state in redux on page load
- React Router and Redux - Data on initial load
- How to fully load data using axios before render
- React with Redux Saga - How to get data back from axios call
- How do I stop state store data from accumulating in a redux component every time I navigate to it using react router
- How to get data from axios call in redux action? React JS search project
- How to create a Redux store using combineReducers without initial state
- Data on redux store return to initial state
More Query from same tag
- Form submission canceled because the form is not connected in react js. Where am I going wrong?
- create 2D dictionary from json file to get counts
- Click on radio button and display the corresponding value inside the radio button as selected in react js material UI design
- React -- Best Way to Create Component that only accepts Text as children prop
- Map within a map in react, getting unexpected token expected ","
- How to dynamically decide to pass a prop to a react component or not?
- My question is about material-ui 4, material-ui/pickers compaining of inexistent "mask" property
- React datepicker disable dates after two weeks
- Having an issue with e.target.value returning Undefined in React
- What's the difference between useCallback and useMemo
- React state don't update a filter on a component
- How to pass props to child React component?
- First container rendered have no data from api fetch in React
- react markdown type for paragraph renderer?
- react-select: (multiselect) How to pass both event object & selectedOptions to event handler?
- Problem with re render component from every time socket send data
- React Form using Winterfell
- ReferenceError : Dispatch is not defined
- React - api data not visible in the ui?
- React-router-dom v4, links in NavBar but routing in App.js
- React - parent class component function change class of child component
- Modify parent component state from child
- Using material ui tabs with react router?
- Ignore click on transparent parts of images
- Migration to React 16.0.0 Error: Cannot find module "react/lib/ReactComponentTreeHook"
- Functions are not valid as a React child. Conditional Rendering through Constant and not function
- Modal Not loading in React using materialize css
- Redux/Toolkits, useSelector Doesn't Work, Why?
- Facing error while installing firebase via npm | Unexpected end of JSON input while parsing near
- Change or Create a component with hooks