You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To use this new `makeStore` function we need to create a new "client" component that will create the store and share it using the React-Redux `Provider` component.
151
151
152
-
```ts title="app/StoreProvider.tsx"
152
+
```tsx title="app/StoreProvider.tsx"
153
153
// file: lib/store.ts noEmit
154
154
import { configureStore } from'@reduxjs/toolkit'
155
155
@@ -172,7 +172,8 @@ export type AppDispatch = AppStore['dispatch']
172
172
import { useRef } from'react'
173
173
import { Provider } from'react-redux'
174
174
// highlight-start
175
-
import { makeStore, AppStore } from'../lib/store'
175
+
importtype { AppStore } from'../lib/store'
176
+
import { makeStore } from'../lib/store'
176
177
// highlight-end
177
178
178
179
exportdefaultfunction StoreProvider({
@@ -206,7 +207,7 @@ The next step is to **include the `StoreProvider` anywhere in the tree above whe
206
207
207
208
If you need to initialize the store with data from the parent component, then define that data as a prop on the client `StoreProvider` component and use a Redux action on the slice to set the data in the store as shown below.
@@ -282,7 +284,7 @@ If you use Next.js's support for client side SPA-style navigation by using `next
282
284
283
285
Shown below is a `ProductName` example component that uses the Redux store to manage the mutable name of a product. The `ProductName` component is part of a product detail route. In order to ensure that we have the correct name in the store we need to set the value in the store any time the `ProductName` component is initially rendered, which happens on any route change to the product detail route.
0 commit comments