Closed frankcollins3 closed 12 months ago
bookmarking that I thought this might've been the problem: const logInOutGoogleSlice = createSlice({ name: 'logInOutGoogle',
// that I accidentally copied the "main" key which would've been weird since I typed it out but you never know. [3:18pm]
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
interface MainSliceState {
👍 // main
HYDRO_SETTINGS: boolean;
👍 // login
LOGIN_SIGNUP_BTN: boolean;
}
const initialState: MainSliceState = {
// main
HYDRO_SETTINGS: false,
// login
LOGIN_SIGNUP_BTN: false
};
const mainSlice = createSlice({
name: 'main',
initialState,
reducers: {
TOGGLE_HYDRO_SETTINGS: (state) => {
state.HYDRO_SETTINGS = !state.HYDRO_SETTINGS;
},
},
});
export const { TOGGLE_HYDRO_SETTINGS } = mainSlice.actions;
export default mainSlice.reducer;
export type MainState = MainSliceState;
👍 this is the system to separate that worked fine in the react-express, react-redux-connect iteration of this app [3:19pm]
👍 combining the state manually rather than deferring to logic to do so fixed it. the variable is definable and asserting ternary based rendering modifications that affect
{ text }
as a test. [3:21pm]this is what was missing, the logInOutGoogle reducer to be exported through the root reducer. found out from chatGPT after asking it an unrelated question about: how to include action.payload in an action function
import { combineReducers } from 'redux'; import passwordReducer from './path/to/passwordSlice';
const rootReducer = combineReducers({ password: passwordReducer, // other reducers... });
export default rootReducer;
👍 👍 👍
[4:22pm]
attempting to do: separate @redux/toolkit state by directory
error: Property 'logInOutGoogle' does not exist on type 'CombinedState<{ main: MainSliceState; }>'.ts(2339) any No quick fixes available
proposed approach: 0: take time learn convention
1: stop wasting time. put state in mainSliceState like original app had it in a global store. save semantics for the following app.