This is the code to my globalContainerStyleSlice.js
import { createSlice } from '@reduxjs/toolkit'
const initialState = {
display: 'flex',
height: '100vh',
overflowY: 'hidden',
flexDirection: 'row',
}
export const globalContainerStyleSlice = createSlice({
name: "globalStyles",
initialState,
reducers: {
setGlobalContainerStyle: (state, action) => {
state.value = action.payload
}
}
})
export const { setGlobalContainerStyle } = globalContainerStyleSlice.actions
export default globalContainerStyleSlice.reducer
As for all the other code, I have gotten it straight from the Redux toolkit quickstart guide, which you can find here: https://redux-toolkit.js.org/tutorials/quick-start The problem, as stated in the title, is that globalStyles is not being initialized as initialState. I am using NextJS, react-redux, and redux toolkit.
This is how I set up store.js
import { configureStore } from '@reduxjs/toolkit'
import userReducer from './slices/userSlice'
import tasksReducer from './slices/tasksSlice'
import globalContainerStyleReducer from './slices/globalContainerStyleSlice'
export const store = configureStore({
reducer: {
user: userReducer,
tasks: tasksReducer,
globalStyles: globalContainerStyleReducer,
},
})