I'm trying to build an app that has two or more
reducers "answering" by one object inside my storeState
.
Example:
storeState {
app: {...},
comments: [ ...two or more states inside one... ]
}
I already tried the following using combineReducers that didn't work, my comments
state became an empty object.
import { combineReducers } from 'redux';
import commentFacebookReducer from './twitch';
import commentYoutubeReducer from './reddit';
import appReducer from './app';
const rootReducer = combineReducers({
comments: [commentFacebookReducer, commentYoutubeReducer],
app: appReducer
});
export default rootReducer;
And I already tried to combine my comment reducers before combine them in rootReducer
:
import { combineReducers } from 'redux';
import commentFacebookReducer from './twitch';
import commentYoutubeReducer from './reddit';
import appReducer from './app';
const commentReducers = combineReducers({
commentFacebookReducer,
commentYoutubeReducer
});
const rootReducer = combineReducers({
comments: commentReducers,
app: appReducer
});
export default rootReducer;
But it gives me a storeState like the following. But I need a state that is an array of comments, I can't deal with these reducers names (like commentFacebookReducer or commentYoutubeReducer), because I'll have thousands of reducers like these.
storeState {
app: {...},
comments: {
commentFacebookReducer: {...},
commentYoutubeReducer: {...}
}
}