I'm trying to create separate reducers for different React components. This is the code:
store.tsx:
const store = createStore(rootReducer, composeWithDevTools());
root.reducers.tsx:
import { combineReducers } from 'redux';
import mainReducer from './main.reducers';
import profileReducers from './components/Profile/Profile.reducers';
const rootReducer = combineReducers({
mainReducer,
profileReducers,
});
export default rootReducer;
main.reducers.tsx:
<...>
function mainReducer(state = initialState, action: AnyAction) {
switch (action.type) {
case HOME_PAGE_MOVIES_ADDED:
return {
...state,
homePageMovies: action.homePageMovies,
};
case MOVIE_SELECTED:
return {
...state,
selectedMovie: action.selectedMovie,
};
default:
return state;
export default mainReducer;
export type RootState = ReturnType<typeof mainReducer>;
profile.reducers.tsx:
interface mainState {
selectedCategory: boolean;
}
const initialState: mainState = {
selectedCategory: false,
};
function profileReducers(state = initialState, action: AnyAction) {
switch (action.type) {
case CATEGORY_SELECTED:
return {
...state,
selectedCategory: action.selectedCategory,
};
default:
return state;
}
}
export default profileReducers;
export type RootState = ReturnType<typeof profileReducers>;
When I try to render UI, I get following error:

I get this error once I replace mainReducer by rootReducer at */store.tsx > const store = createStore(mainReducer, composeWithDevTools());.
What am i missing? Thanks!
