From 5d85c9826819fc2d32384269075c7bec476d616f Mon Sep 17 00:00:00 2001 From: Mohammad Amin <42641117+aminsoheyli@users.noreply.github.com> Date: Mon, 26 Aug 2019 16:46:29 +0430 Subject: [PATCH 1/2] add a line to insist on the pure nature add a line to insist on the pure nature of mapStateToProps function --- .../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 d304d96b2..0814659d5 100644 --- a/docs/using-react-redux/connect-extracting-data-with-mapStateToProps.md +++ b/docs/using-react-redux/connect-extracting-data-with-mapStateToProps.md @@ -112,7 +112,7 @@ As part of the "re-shaping data" idea, `mapStateToProps` functions frequently ne ### `mapStateToProps` Functions Should Be Pure and Synchronous -Much like a Redux reducer, a `mapStateToProps` function should always be 100% pure and synchronous. It should simply take `state` (and `ownProps`) as arguments, and return the data the component needs as props. It should _not_ be used to trigger asynchronous behavior like AJAX calls for data fetching, and the functions should not be declared as `async`. +Much like a Redux reducer, a `mapStateToProps` function should always be 100% pure and synchronous. It should simply take `state` (and `ownProps`) as arguments, and return the data the component needs as props. It should _not_ be used to trigger asynchronous behavior like AJAX calls for data fetching, and the functions should not be declared as `async`. Also it should not mutate the `state` or the `ownProps`. ## `mapStateToProps` and Performance From 4bd70e0f47ec622de2ac5c545e037db043a15877 Mon Sep 17 00:00:00 2001 From: Tim Dorr Date: Mon, 26 Aug 2019 10:14:38 -0400 Subject: [PATCH 2/2] Reorder --- .../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 0814659d5..c9f3455a1 100644 --- a/docs/using-react-redux/connect-extracting-data-with-mapStateToProps.md +++ b/docs/using-react-redux/connect-extracting-data-with-mapStateToProps.md @@ -112,7 +112,7 @@ As part of the "re-shaping data" idea, `mapStateToProps` functions frequently ne ### `mapStateToProps` Functions Should Be Pure and Synchronous -Much like a Redux reducer, a `mapStateToProps` function should always be 100% pure and synchronous. It should simply take `state` (and `ownProps`) as arguments, and return the data the component needs as props. It should _not_ be used to trigger asynchronous behavior like AJAX calls for data fetching, and the functions should not be declared as `async`. Also it should not mutate the `state` or the `ownProps`. +Much like a Redux reducer, a `mapStateToProps` function should always be 100% pure and synchronous. It should only take `state` (and `ownProps`) as arguments, and return the data the component needs as props without mutating those arguments. It should _not_ be used to trigger asynchronous behavior like AJAX calls for data fetching, and the functions should not be declared as `async`. ## `mapStateToProps` and Performance