score:5
Accepted answer
don't combine them into booksmangereducer
. instead, just export them all as named exports and combine all the reducers at once:
export {
books,
employees,
employeeslist,
bookspagination,
booksstate
};
then import them all:
import {
books,
employees,
employeeslist,
bookspagination,
booksstate
} from './booksmanagereducer'
then combine them all individually with combinereducers
:
combinereducers({
books,
employees,
employeeslist,
bookspagination,
booksstate,
companyid,
routing: routerreducer
});
combinereducers
uses the keys of the passed object to construct state. this will give the desired hierarchy.
another way which is similar to what you're doing could be exporting an object containing all the reducers themselves, then import the object and spreading it:
export default {
//books, employees, etc.
};
then:
import reducers from './booksmanagereducer';
finally:
combinereducers({
...reducers,
companyid,
routing: routerreducer
});
Source: stackoverflow.com
Related Query
- Nesting `combineReducers` doesn't let to have state without nested objects
- How to update state of nested array of array of objects without mutating
- Updating state with nested array of objects without mutation
- React: Setting State for Deeply Nested Objects w/ Hooks
- Update state from deeply nested component without re-rendering parents
- React State update a nested array with objects based on the id when iterated
- ReactJS: Update nested state object properties without replacing whole object using setState()
- Changing state of object nested in array of objects
- Is it okay to have pointers to old state objects in React Redux?
- Using nested objects in redux initial state and reducers
- Using nested objects with Flow in React state
- Redux - modifying state of a nested array of objects
- Update react State array of nested objects
- React - using nested objects as state with hooks to fill form data
- How to create a Redux store using combineReducers without initial state
- React: How can I map nested JSON Objects without key name
- How to update nested objects state of array in redux?
- Update state dynamically with nested levels of objects and array
- javascript / react - switching the properties of two objects in an array in react state without triggering a re-render
- Updating nested state in objects through an input element in React
- How to propagate state to the root of nested tree from a deep node without using Flux?
- React - write and read nested objects in state
- Updating multiple attributes of a nested state array of objects from a dynamic object
- Is there any way to pass accessors nested json without knowing the nesting keys. Table throws error
- How to copy nested state between objects in React
- How do I pull a nested state object without it returning as "undefined"
- how to have set state for sibling component in React without updating
- Storing nested objects in React State
- Redux reducers adding nested objects to state
- Redux nested objects as state - is this possible/optimal
More Query from same tag
- In React Login component Firebase Login signup is working but when I am trying to send a reset password Link then is Not sending to email
- how can i change the status of the username in reactjs using axios?
- Can I style different unordered list items separately?
- Add default open logic for a react Collapse component
- How to sinon spy a React component constructor - unit testing?
- React-native bundling failure. ERROR MESSAGE: "While trying to resolve module 'idb'..... Indeed none of these files exist":
- Is it possible to run React project without npm start?
- Want to route one component to another component
- Why does Javascript .filter() not return anything with an active filter (== or ===) but works fine if the boolean logic is of type != or !==?
- Prevent props using propTypes
- Cannot read property 'user' of undefined, React Redux
- Why is react throwing an error
- Form submit not working for the React Food App
- Test if function is called react and enzyme
- "Error: Function components cannot have string refs" when I don't use string ref
- React.JS npm start error after successful installation of all packages using create-react-app
- How to map data of a field in an JSON object which is an array of objects
- React Child component does not rerender on prop change
- How to use react-redux in Visual Studio
- Code for passing user information from azureAD to app.js
- How to refresh in React Navigation
- React checkbox feature with only single selection
- Material Ui Grid doesn't scale properly
- How manage global state using context API in React js
- BrowserslistError: Unknown browser query `dead` in React/Express App
- TypeScript React <img /> onLoad event.target can't find naturalWidth naturalHeight
- Console.log not working on Reactjs app
- State is not updating immediately after onClick in react js
- Reading JSON data with axios and React
- How to pass contenteditable attribute to html?