score:1
either would work. the only thing that comes to mind is that, without an initial state, it doesn't really fit the definition of a redux reducer; it would not work in isolation, since redux expects the initial state to not be undefined.
in any case it's rather innocuous to set an initial state on the sub-reducer as
export default function stats(state = {}, action) {
// ... whwtever
}
Source: stackoverflow.com
Related Query
- Setting the initial state of redux in reducers
- React redux setting initial state from axios call
- Setting initial state from Redux
- Typescript - Setting the type for a null property, when defining the initial state in Redux
- Using nested objects in redux initial state and reducers
- Redux Toolkit - Setting initial state using RTK Query
- React / Redux - setting initial state with useRouteMatch
- Setting the initial state using next react redux wrapper
- react router redux initial state setting on isomorphic app
- Setting Initial State to response from API with REDUX
- Setting initial state in Redux sub-reducers
- Read Store's Initial State in Redux Reducer
- how to set initial state in redux
- Redux reducers -- changing deeply-nested state
- Right way to update state in redux reducers
- Typescript and React setting initial state with empty typed array
- Redux React create initial state from API
- Redux reducers initializing same state key
- How to compose redux reducers with dependent state
- How to pass redux state to sub routes?
- WebStorm inspector throws warning when setting initial React state with ES6
- how can we use redux state in useState to set initial values
- Redux actions/reducers vs. directly setting state
- Reactjs Redux should we create sub reducer for every object in the state tree?
- combineReducers destroys Redux state and also breaks multi ImmutableJs reducers
- How to reset the state to it's initial state in redux store?
- Which is better practice for setting state in react redux
- Redux initial state gets mutated even when using Object.assign
- Initial state in React with Redux not working
- How to return state of Redux reducers
More Query from same tag
- using same props of caller component
- ReactJS map through an array with objects
- React custom hook with useContext functions
- React PropTypes: Allow different types of PropTypes for one prop
- Unable to render output of an API call made from a text field unto the UI
- Onepage with Gatsby JS and Contentful, how to import my first simple string
- Unpacking an array and returning its elements
- React-spring - Animated div removes onclick function
- firebase.firestore.FieldValue.delete() not deleting field in document
- React Css Themr not working
- groupBy json data then map in React component
- Will react automatically remove eventlisteners when a component unmounts?
- Empty response from API with React
- REACT TypeError: Class extends value undefined is not a constructor or null
- Clear Select component after an option is selected in Ant Design and React
- ReactJS - rerender same component with different data?
- Nodemon and/or Hot Reloading with a Node-React Web App
- Firebase: No Firebase App '[DEFAULT]' has been created when using Reserved Hosting URL
- ReactJS & MobX: TypeError: ... is not a function - but it is?
- React JS (JSX) div not rendering unless text is added to div
- TypeError: Cannot read property 'startsWith' of undefined in router.pathname.startsWith()
- Can we add events on react fragment?
- How to use synchronous and asynchronous functions inside onClick method in React
- How to sort list of React components based on different properties?
- ReactJS add callback function to children component
- React modal animation on click
- How to use function inside JSX
- Reactjs: Cannot read URL property of null, fetching from an API
- Server status 400 blocks json from sending response to client
- React component doesn't get current state value in Event Listener function