From dc919fd2fe3adb99f270d861722b2b700e21da7d Mon Sep 17 00:00:00 2001 From: Aroyan <43630681+aroyan@users.noreply.github.com> Date: Wed, 11 May 2022 18:49:30 +0800 Subject: [PATCH 1/3] fix(docs): update broken link Update broken link for "Improving React and Redux performance with Reselect" --- .../connect-extracting-data-with-mapStateToProps.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/using-react-redux/connect-extracting-data-with-mapStateToProps.md b/docs/using-react-redux/connect-extracting-data-with-mapStateToProps.md index c0a41bc3e..6f3ff30cb 100644 --- a/docs/using-react-redux/connect-extracting-data-with-mapStateToProps.md +++ b/docs/using-react-redux/connect-extracting-data-with-mapStateToProps.md @@ -221,7 +221,7 @@ function mapStateToProps(...args) { **Performance** - [Lee Byron's Tweet Suggesting to avoid `toJS`, `toArray` and `toObject` for Performance](https://twitter.com/leeb/status/746733697093668864) -- [Improving React and Redux performance with Reselect](https://blog.rangle.io/react-and-redux-performance-with-reselect/) +- [Improving React and Redux performance with Reselect](https://rangle.io/blog/react-and-redux-performance-with-reselect/) - [Immutable data performance links](https://github.com/markerikson/react-redux-links/blob/master/react-performance.md#immutable-data) **Q&A** From 6e219ee77a7c309d2599061ee2a771247fc964f5 Mon Sep 17 00:00:00 2001 From: Oleg Kuzava Date: Fri, 20 May 2022 11:38:46 +0300 Subject: [PATCH 2/3] show warning instead of throwing error that pure option has been removed --- src/components/connect.tsx | 8 +++-- test/components/connect.spec.tsx | 61 ++++++++++++++++++++++++++++++-- 2 files changed, 64 insertions(+), 5 deletions(-) diff --git a/src/components/connect.tsx b/src/components/connect.tsx index e5c19499d..19116df41 100644 --- a/src/components/connect.tsx +++ b/src/components/connect.tsx @@ -28,6 +28,7 @@ import { mergePropsFactory } from '../connect/mergeProps' import { createSubscription, Subscription } from '../utils/Subscription' import { useIsomorphicLayoutEffect } from '../utils/useIsomorphicLayoutEffect' import shallowEqual from '../utils/shallowEqual' +import warning from '../utils/warning' import { ReactReduxContext, @@ -405,6 +406,8 @@ export interface Connect { // tslint:enable:no-unnecessary-generics } +let hasWarnedAboutDeprecatedPureOption = false + /** * Connects a React component to a Redux store. * @@ -452,8 +455,9 @@ function connect< }: ConnectOptions = {} ): unknown { if (process.env.NODE_ENV !== 'production') { - if (pure !== undefined) { - throw new Error( + if (pure !== undefined && !hasWarnedAboutDeprecatedPureOption) { + hasWarnedAboutDeprecatedPureOption = true + warning( 'The `pure` option has been removed. `connect` is now always a "pure/memoized" component' ) } diff --git a/test/components/connect.spec.tsx b/test/components/connect.spec.tsx index 1007b03ad..310895509 100644 --- a/test/components/connect.spec.tsx +++ b/test/components/connect.spec.tsx @@ -2912,6 +2912,57 @@ describe('React', () => { expect.stringContaining('was not wrapped in act') ) } + + spy.mockRestore() + }) + + it('should warn one-time-only that `pure` options has been removed', () => { + const spy = jest.spyOn(console, 'error').mockImplementation(() => {}) + const store: Store = createStore(stringBuilder) + + class ContainerA extends Component { + render() { + return + } + } + + const ConnectedContainerA = connect( + (state) => ({ string: state }), + () => ({}), + () => ({}), + // The `pure` option has been removed + // @ts-ignore + { pure: true } + )(ContainerA) + + class ContainerB extends Component { + render() { + return + } + } + + const ConnectedContainerB = connect( + (state) => ({ string: state }), + () => ({}), + () => ({}), + // The `pure` option has been removed + // @ts-ignore + { pure: true } + )(ContainerB) + + rtl.render( + + + + + ) + + expect(spy).toHaveBeenCalledTimes(1) + expect(spy).toHaveBeenCalledWith( + 'The `pure` option has been removed. `connect` is now always a "pure/memoized" component' + ) + + spy.mockRestore() }) }) @@ -3236,9 +3287,13 @@ describe('React', () => { ) - store.dispatch({ type: '' }) - store.dispatch({ type: '' }) - outerComponent.current!.setState(({ count }) => ({ count: count + 1 })) + rtl.act(() => { + store.dispatch({ type: '' }) + store.dispatch({ type: '' }) + outerComponent.current!.setState(({ count }) => ({ + count: count + 1, + })) + }) expect(reduxCountPassedToMapState).toEqual(3) }) From d0311c1bf4c0125132329faeab8ad41f5f0f749a Mon Sep 17 00:00:00 2001 From: Mark Erikson Date: Sun, 22 May 2022 15:20:13 -0400 Subject: [PATCH 3/3] Release 8.0.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index acf023a8c..818fdc023 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-redux", - "version": "8.0.1", + "version": "8.0.2", "description": "Official React bindings for Redux", "keywords": [ "react",