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
Copy file name to clipboardExpand all lines: docs/tutorials/quick-start.mdx
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -68,7 +68,7 @@ This creates a Redux store, and also automatically configure the Redux DevTools
68
68
69
69
Once the store is created, we can make it available to our React components by putting a React-Redux `<Provider>` around our application in `src/index.js`. Import the Redux store we just created, put a `<Provider>` around your `<App>`, and pass the store as a prop:
70
70
71
-
```tstitle="index.js"
71
+
```tstitle="index.ts"
72
72
// file: App.tsx noEmit
73
73
importReactfrom'react'
74
74
exportdefaultfunction App() {
@@ -109,7 +109,7 @@ Creating a slice requires a string name to identify the slice, an initial state
109
109
110
110
Redux requires that [we write all state updates immutably, by making copies of data and updating the copies](https://redux.js.org/tutorials/fundamentals/part-2-concepts-data-flow#immutability). However, Redux Toolkit's `createSlice` and `createReducer` APIs use [Immer](https://immerjs.github.io/immer/) inside to allow us to [write "mutating" update logic that becomes correct immutable updates](https://redux.js.org/tutorials/fundamentals/part-8-modern-redux#immutable-updates-with-immer).
Next, we need to import the reducer function from the counter slice and add it to our store. By defining a field inside the `reducer` parameter, we tell the store to use this slice reducer function to handle all updates to that state.
153
153
154
-
```ts title="app/store.js"
154
+
```ts title="app/store.ts"
155
155
// file: features/counter/counterSlice.ts noEmit
156
156
import { createSlice } from'@reduxjs/toolkit'
157
157
@@ -185,7 +185,7 @@ export type AppDispatch = typeof store.dispatch
185
185
186
186
Now we can use the React-Redux hooks to let React components interact with the Redux store. We can read data from the store with `useSelector`, and dispatch actions using `useDispatch`. Create a `src/features/counter/Counter.js` file with a `<Counter>` component inside, then import that component into `App.js` and render it inside of `<App>`.
0 commit comments