dustingetz / react-cursor

Immutable state for React.js
1.03k stars 50 forks source link

2.0 branch broke cursor ref equality against react components #73

Closed dustingetz closed 8 years ago

dustingetz commented 8 years ago

root cause being cmp.setState.bind(cmp) !== cmp.setState.bind(cmp)

dustingetz commented 8 years ago

Resolved it by explicitly supporting the old cursor.build api is supported in this branch. We detect this overload of cursor.build by detecting react component instances, and memoize the setState function before building the cursor. The memoizer is required because cmp.setState is not autobound by React.