Skip to content

Commit ae4c0ca

Browse files
authored
Merge branch 'master' into feat/create-hooks-api
2 parents e9631ae + c83ae48 commit ae4c0ca

File tree

13 files changed

+60
-32
lines changed

13 files changed

+60
-32
lines changed

docs/api/batch.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ hide_title: true
1111
batch(fn: Function)
1212
```
1313

14-
React's `unstable_batchedUpdate()` API allows any React updates in an event loop tick to be batched together into a single render pass. React already uses this internally for its own event handler callbacks. This API is actually part of the renderer packages like ReactDOM and React Native, not the React core itself.
14+
React's `unstable_batchedUpdates()` API allows any React updates in an event loop tick to be batched together into a single render pass. React already uses this internally for its own event handler callbacks. This API is actually part of the renderer packages like ReactDOM and React Native, not the React core itself.
1515

1616
Since React-Redux needs to work in both ReactDOM and React Native environments, we've taken care of importing this API from the correct renderer at build time for our own use. We also now re-export this function publicly ourselves, renamed to `batch()`. You can use it to ensure that multiple actions dispatched outside of React only result in a single render update, like this:
1717

@@ -31,4 +31,4 @@ function myThunk() {
3131

3232
## References
3333

34-
- [`unstable_batchedUpdate()` API from React](https://github.com/facebook/react/commit/b41883fc708cd24d77dcaa767cde814b50b457fe)
34+
- [`unstable_batchedUpdates()` API from React](https://github.com/facebook/react/commit/b41883fc708cd24d77dcaa767cde814b50b457fe)

docs/api/hooks.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ The selector is approximately equivalent to the [`mapStateToProps` argument to `
4646
However, there are some differences between the selectors passed to `useSelector()` and a `mapState` function:
4747

4848
- The selector may return any value as a result, not just an object. The return value of the selector will be used as the return value of the `useSelector()` hook.
49-
- When an action is dispatched, `useSelector()` will do a shallow comparison of the previous selector result value and the current result value. If they are different, the component will be forced to re-render. If they are the same, they component will not re-render.
49+
- When an action is dispatched, `useSelector()` will do a reference comparison of the previous selector result value and the current result value. If they are different, the component will be forced to re-render. If they are the same, the component will not re-render.
5050
- The selector function does _not_ receive an `ownProps` argument. However, props can be used through closure (see the examples below) or by using a curried selector.
5151
- Extra care must be taken when using memoizing selectors (see examples below for more details).
5252
- `useSelector()` uses strict `===` reference equality checks by default, not shallow equality (see the following section for more details).
@@ -171,7 +171,7 @@ export const App = () => {
171171
}
172172
```
173173

174-
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 thourough explanation of why this is necessary):
174+
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):
175175

176176
```jsx
177177
import React, { useMemo } from 'react'
@@ -415,14 +415,14 @@ export function useActions(actions, deps) {
415415
return actions.map(a => bindActionCreators(a, dispatch))
416416
}
417417
return bindActionCreators(actions, dispatch)
418-
}, deps ? [dispatch, ...deps] : deps)
418+
}, deps ? [dispatch, ...deps] : [dispatch])
419419
}
420420
```
421421

422422
### Recipe: `useShallowEqualSelector()`
423423

424424
```js
425-
import { shallowEqual } from 'react-redux'
425+
import { useSelector, shallowEqual } from 'react-redux'
426426

427427
export function useShallowEqualSelector(selector) {
428428
return useSelector(selector, shallowEqual)

docs/introduction/quick-start.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ sidebar_label: Quick Start
1111

1212
## Installation
1313

14-
React Redux 6.x requires **React 16.4 or later.**
14+
React Redux 7.1 requires **React 16.8.3 or later.**
1515

1616
To use React Redux with your React app:
1717

package-lock.json

Lines changed: 42 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"@babel/plugin-transform-runtime": "^7.4.4",
5858
"@babel/preset-env": "^7.4.5",
5959
"@testing-library/react": "^8.0.1",
60+
"@testing-library/react-hooks": "^1.1.0",
6061
"babel-eslint": "^10.0.1",
6162
"babel-jest": "^24.8.0",
6263
"codecov": "^3.5.0",
@@ -74,7 +75,6 @@
7475
"prettier": "^1.18.2",
7576
"react": "^16.8.6",
7677
"react-dom": "^16.8.6",
77-
"react-hooks-testing-library": "^0.5.1",
7878
"react-test-renderer": "^16.8.6",
7979
"redux": "^4.0.1",
8080
"rimraf": "^2.6.3",

src/components/Provider.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ class Provider extends Component {
2222
}
2323

2424
componentDidMount() {
25-
this._isMounted = true
26-
2725
this.state.subscription.trySubscribe()
2826

2927
if (this.previousState !== this.props.store.getState()) {
@@ -35,8 +33,6 @@ class Provider extends Component {
3533
if (this.unsubscribe) this.unsubscribe()
3634

3735
this.state.subscription.tryUnsubscribe()
38-
39-
this._isMounted = false
4036
}
4137

4238
componentDidUpdate(prevProps) {

src/hooks/useDispatch.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,14 @@ export function createDispatchHook(context = ReactReduxContext) {
1717
}
1818

1919
/**
20-
* A hook to access the redux `dispatch` function. Note that in most cases where you
21-
* might want to use this hook it is recommended to use `useActions` instead to bind
22-
* action creators to the `dispatch` function.
20+
* A hook to access the redux `dispatch` function.
2321
*
2422
* @returns {any|function} redux store's `dispatch` function
2523
*
2624
* @example
2725
*
2826
* import React, { useCallback } from 'react'
29-
* import { useReduxDispatch } from 'react-redux'
27+
* import { useDispatch } from 'react-redux'
3028
*
3129
* export const CounterComponent = ({ value }) => {
3230
* const dispatch = useDispatch()

test/hooks/useDispatch.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
22
import { createStore } from 'redux'
3-
import { renderHook } from 'react-hooks-testing-library'
3+
import { renderHook } from '@testing-library/react-hooks'
44
import {
55
Provider as ProviderMock,
66
useDispatch,

test/hooks/useReduxContext.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { renderHook } from 'react-hooks-testing-library'
1+
import { renderHook } from '@testing-library/react-hooks'
22
import { useReduxContext } from '../../src/hooks/useReduxContext'
33

44
describe('React', () => {

test/hooks/useSelector.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import React, { useCallback, useReducer } from 'react'
44
import { createStore } from 'redux'
5-
import { renderHook, act } from 'react-hooks-testing-library'
5+
import { renderHook, act } from '@testing-library/react-hooks'
66
import * as rtl from '@testing-library/react'
77
import {
88
Provider as ProviderMock,

website/pages/en/versions.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ const versions = require(`${CWD}/versions.json`)
1919
const versionToReleaseTags = {
2020
'5.x': '5.0.0',
2121
'6.x': '6.0.0',
22-
'7.x': '7.0.1'
22+
'7.0': '7.0.0',
23+
'7.1': '7.1.0'
2324
}
2425

2526
function Versions() {

website/versioned_docs/version-7.1/api/hooks.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ The selector is approximately equivalent to the [`mapStateToProps` argument to `
4646
However, there are some differences between the selectors passed to `useSelector()` and a `mapState` function:
4747

4848
- The selector may return any value as a result, not just an object. The return value of the selector will be used as the return value of the `useSelector()` hook.
49-
- When an action is dispatched, `useSelector()` will do a shallow comparison of the previous selector result value and the current result value. If they are different, the component will be forced to re-render. If they are the same, they component will not re-render.
49+
- When an action is dispatched, `useSelector()` will do a shallow comparison of the previous selector result value and the current result value. If they are different, the component will be forced to re-render. If they are the same, the component will not re-render.
5050
- The selector function does _not_ receive an `ownProps` argument. However, props can be used through closure (see the examples below) or by using a curried selector.
5151
- Extra care must be taken when using memoizing selectors (see examples below for more details).
5252
- `useSelector()` uses strict `===` reference equality checks by default, not shallow equality (see the following section for more details).
@@ -171,7 +171,7 @@ export const App = () => {
171171
}
172172
```
173173

174-
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 thourough explanation of why this is necessary):
174+
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):
175175

176176
```jsx
177177
import React, { useMemo } from 'react'

website/versioned_docs/version-7.1/introduction/quick-start.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ original_id: quick-start
1212

1313
## Installation
1414

15-
React Redux 6.x requires **React 16.4 or later.**
15+
React Redux 7.1 requires **React 16.8.3 or later.**
1616

1717
To use React Redux with your React app:
1818

0 commit comments

Comments
 (0)