Skip to content

Commit fee8190

Browse files
committed
Update 7.x docs with edits from master
1 parent 9306158 commit fee8190

File tree

5 files changed

+13
-9
lines changed

5 files changed

+13
-9
lines changed

docs/api/connect.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ const mapStateToProps = (state, ownProps) => ({
7070
7171
Your `mapStateToProps` functions are expected to return an object. This object, normally referred to as `stateProps`, will be merged as props to your connected component. If you define `mergeProps`, it will be supplied as the first parameter to `mergeProps`.
7272
73-
The return of the `mapStateToProps` determine whether the connected component will re-render (details [here](../using-react-redux/connect-mapstate#return-values-determine-if-your-component-re-renders)).
73+
The return of the `mapStateToProps` determine whether the connected component will re-render (details [here](../using-react-redux/connect-extracting-data-with-mapStateToProps.md#return-values-determine-if-your-component-re-renders)).
7474
75-
For more details on recommended usage of `mapStateToProps`, please refer to [our guide on using `mapStateToProps`](../using-react-redux/connect-mapstate).
75+
For more details on recommended usage of `mapStateToProps`, please refer to [our guide on using `mapStateToProps`](../using-react-redux/connect-extracting-data-with-mapStateToProps.md).
7676
7777
> You may define `mapStateToProps` and `mapDispatchToProps` as a factory function, i.e., you return a function instead of an object. In this case your returned function will be treated as the real `mapStateToProps` or `mapDispatchToProps`, and be called in subsequent calls. You may see notes on [Factory Functions](#factory-functions) or our guide on performance optimizations.
7878

docs/api/hooks.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ The selector function should be [pure](https://en.wikipedia.org/wiki/Pure_functi
5555

5656
:::
5757

58-
The selector is approximately equivalent to the [`mapStateToProps` argument to `connect`](../using-react-redux/connect-mapstate) conceptually. The selector will be called with the entire Redux store state as its only argument. The selector will be run whenever the function component renders (unless its reference hasn't changed since a previous render of the component so that a cached result can be returned by the hook without re-running the selector). `useSelector()` will also subscribe to the Redux store, and run your selector whenever an action is dispatched.
58+
The selector is approximately equivalent to the [`mapStateToProps` argument to `connect`](../using-react-redux/connect-extracting-data-with-mapStateToProps.md) conceptually. The selector will be called with the entire Redux store state as its only argument. The selector will be run whenever the function component renders (unless its reference hasn't changed since a previous render of the component so that a cached result can be returned by the hook without re-running the selector). `useSelector()` will also subscribe to the Redux store, and run your selector whenever an action is dispatched.
5959

6060
However, there are some differences between the selectors passed to `useSelector()` and a `mapState` function:
6161

@@ -190,7 +190,7 @@ export const App = () => {
190190
}
191191
```
192192

193-
However, when the selector is used in multiple component instances and depends on the component's props, you need to ensure that each component instance gets its own selector instance (see [here](https://github.com/reduxjs/reselect#accessing-react-props-in-selectors) for a more thorough explanation of why this is necessary):
193+
However, when the selector is used in multiple component instances and depends on the component's props, you need to ensure that each component instance gets its own selector instance (see [here](https://github.com/reduxjs/reselect#q-can-i-share-a-selector-across-multiple-component-instances) for a more thorough explanation of why this is necessary):
194194

195195
```jsx
196196
import React, { useMemo } from 'react'
@@ -290,7 +290,7 @@ However, the React hooks lint rules do not know that `dispatch` should be stable
290290
should be added to dependency arrays for `useEffect` and `useCallback`. The simplest solution is to do just that:
291291

292292
````js
293-
export const Todos() = () => {
293+
export const Todos = () => {
294294
const dispatch = useDispatch();
295295

296296
useEffect(() => {
@@ -481,4 +481,3 @@ export function useShallowEqualSelector(selector) {
481481
### Additional considerations when using hooks
482482
483483
There are some architectural trade offs to take into consideration when deciding whether to use hooks or not. Mark Erikson summarizes these nicely in his two blog posts [Thoughts on React Hooks, Redux, and Separation of Concerns](https://blog.isquaredsoftware.com/2019/07/blogged-answers-thoughts-on-hooks/) and [Hooks, HOCs, and Tradeoffs](https://blog.isquaredsoftware.com/2019/09/presentation-hooks-hocs-tradeoffs/).
484-
````

docs/troubleshooting.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ In short,
2525
If you have context issues,
2626

2727
1. [Make sure you don’t have a duplicate instance of React](https://medium.com/@dan_abramov/two-weird-tricks-that-fix-react-7cf9bbdef375) on the page.
28-
2. Make sure you didn’t forget to wrap your root or some other ancestor component in [`<Provider>`](#provider-store).
29-
3. Make sure you’re running the latest versions of React and React Redux.
28+
2. Make sure you don't have multiple instances/copies of React Redux in your project.
29+
3. Make sure you didn’t forget to wrap your root or some other ancestor component in [`<Provider>`](#provider-store).
30+
4. Make sure you’re running the latest versions of React and React Redux.
3031

3132
### Invariant Violation: addComponentAsRefTo(...): Only a ReactOwner can have refs. This usually means that you’re trying to add a ref to a component that doesn’t have an owner
3233

docs/tutorials/quick-start.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export default configureStore({
143143
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>`.
144144

145145
```jsx title="features/counter/Counter.js"
146-
import React, { useState } from 'react'
146+
import React from 'react'
147147
import { useSelector, useDispatch } from 'react-redux'
148148
import { decrement, increment } from './counterSlice'
149149
import styles from './Counter.module.css'

docs/using-react-redux/accessing-store.md

+4
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ The following runtime error occurs when React Redux does not find a store in the
7575
>
7676
> Could not find "store" in the context of "Connect(MyComponent)". Either wrap the root component in a `<Provider>`, or pass a custom React context provider to `<Provider>` and the corresponding React context consumer to Connect(Todo) in connect options.
7777
78+
### Custom Context and the hooks API
79+
80+
To access the custom context via the hooks API, you can create custom hooks via the [hook creator functions](../api/hooks.md#custom-context).
81+
7882
## Multiple Stores
7983

8084
[Redux was designed to use a single store](https://redux.js.org/api/store#a-note-for-flux-users).

0 commit comments

Comments
 (0)