-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redux Toolkit #83
Comments
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);
},
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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..
The text was updated successfully, but these errors were encountered: