frankcollins3 / Next-Water-App

Happy, Healthy Water Cycling App that tracks user/human fluid intake.
https://next-water-app.vercel.app
1 stars 0 forks source link

property does not exist on type CombinedState [3:14pm] #34

Closed frankcollins3 closed 12 months ago

frankcollins3 commented 12 months ago

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.

frankcollins3 commented 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]

frankcollins3 commented 12 months ago
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]

frankcollins3 commented 12 months ago

👍 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]

frankcollins3 commented 12 months ago

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]