Open iot-cpars opened 2 years ago
I would be interested to see an example of this too.
Thank you
What i ended up doing is wraping my getServerSideProps with a method that writes my access token into the Redux store and then i can read it out of the store in the prepareHeaders function. That way i can automate the token handling. But maybe there is a better cookie based way
import { createSlice } from '@reduxjs/toolkit';
import { HYDRATE } from 'next-redux-wrapper';
import { initialRouterState, routerReducer } from 'connected-next-router';
export const routerSlice = createSlice({
name: 'router',
initialState: initialRouterState(),
reducers: {},
extraReducers: (builder) => {
builder
// for next-redux-wrapper hydration
.addCase(HYDRATE, (state, { payload }) => ({
...state,
...payload.router,
}))
.addDefaultCase(routerReducer);
},
});
Hi there, this is less of an issue and more of a request.
Could you maybe make an example of how to use this with redux.toolkit and slices?
I tryed getting it working but am rather new to redux.
Thanks a lot..