I'm trying to debug this chat application but I can't open the Redux Dev Tools. I just get a message in the redux console saying "No store found. Make sure to follow the instructions"
The app is not using Redux Toolkit.
Whats wrong with this store?
/store/index.js
import { createStore, applyMiddleware, combineReducers } from "redux";
import loggerMiddleware from "redux-logger";
import thunkMiddleware from "redux-thunk";
import user from "./user";
import conversations from "./conversations";
import activeConversation from "./activeConversation";
const CLEAR_ON_LOGOUT = "CLEAR_ON_LOGOUT";
export const clearOnLogout = () => {
return {
type: CLEAR_ON_LOGOUT,
};
};
const appReducer = combineReducers({
user,
conversations,
activeConversation,
});
const rootReducer = (state, action) => {
if (action.type === CLEAR_ON_LOGOUT) {
// set state to initial state
state = undefined;
}
return appReducer(state, action);
};
export const store = createStore(
rootReducer,
applyMiddleware(thunkMiddleware, loggerMiddleware)
);
console.log(store.getState());
export default store;
This is the error logged in the console
action SET_MESSAGE @ 10:32:54.246 redux-logger.js:1
prev state
Object { user: {…}, conversations: (2) […], activeConversation: "hualing" }
redux-logger.js:1
action
Object { type: "SET_MESSAGE", payload: {…} }
redux-logger.js:1
error TypeError: message is undefined
addMessageToStore reducerFunctions.js:15
addMessageToStore reducerFunctions.js:14
reducer conversations.js:77
combination Redux
rootReducer index.js:27
Redux 4
postMessage thunkCreators.js:103
middleware Redux
postMessage Input.js:61
handleSubmit Input.js:38
React 14
unstable_runWithPriority scheduler.development.js:468
React 15
js index.js:7
js main.chunk.js:4097
Webpack 7
redux-logger.js:1
next state
Object { user: {…}, conversations: (2) […], activeConversation: "hualing" }