From 38630b0dc8b21cae621ff0875756ae0805889b9f Mon Sep 17 00:00:00 2001 From: Cole Turner Date: Mon, 24 Apr 2017 15:02:09 -0400 Subject: [PATCH] Remove state between connectAdvanced calls in example When I saw this example I was initially excited by the prospect of storing `state` between `connectAdvanced` calls. I thought of the uses like storing the deleted todo items, or even just the count. But then it dawned on me that the idiomatic approach to Redux, such as the ability for time travel - is challenged when the previous state is stored. For newbies like myself, suggesting this in documentation can be misleading and might encourage the wrong practice. --- docs/api.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/api.md b/docs/api.md index a2665f746..a12e81070 100644 --- a/docs/api.md +++ b/docs/api.md @@ -361,7 +361,6 @@ import * as actionCreators from './actionCreators' import { bindActionCreators } from 'redux' function selectorFactory(dispatch) { - let state = {} let ownProps = {} let result = {} const actions = bindActionCreators(actionCreators, dispatch) @@ -369,7 +368,6 @@ function selectorFactory(dispatch) { return (nextState, nextOwnProps) => { const todos = nextState.todos[nextProps.userId] const nextResult = { ...nextOwnProps, todos, addTodo } - state = nextState ownProps = nextOwnProps if (!shallowEqual(result, nextResult)) result = nextResult return result