Skip to content

Commit 73e5d2c

Browse files
coleturnertimdorr
authored andcommitted
Remove state between connectAdvanced calls in example (#685)
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.
1 parent e6400f3 commit 73e5d2c

File tree

1 file changed

+0
-2
lines changed

1 file changed

+0
-2
lines changed

docs/api.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,15 +361,13 @@ import * as actionCreators from './actionCreators'
361361
import { bindActionCreators } from 'redux'
362362

363363
function selectorFactory(dispatch) {
364-
let state = {}
365364
let ownProps = {}
366365
let result = {}
367366
const actions = bindActionCreators(actionCreators, dispatch)
368367
const addTodo = (text) => actions.addTodo(ownProps.userId, text)
369368
return (nextState, nextOwnProps) => {
370369
const todos = nextState.todos[nextProps.userId]
371370
const nextResult = { ...nextOwnProps, todos, addTodo }
372-
state = nextState
373371
ownProps = nextOwnProps
374372
if (!shallowEqual(result, nextResult)) result = nextResult
375373
return result

0 commit comments

Comments
 (0)