esamattis / redux-hooks

⚓ React Hooks implementation for Redux
http://npm.im/@epeli/redux-hooks
MIT License
96 stars 4 forks source link

Can useReduxState be used when mapStateToProps depends on component's own props? #1

Closed elenabratanova closed 5 years ago

elenabratanova commented 5 years ago

@epeli many thanks for the lib! I've been playing with it today, and noticed this issue: Example scenario: there's a cache of whatever in redux and we want to select data based on some id passed to component. Like so: https://codesandbox.io/s/1qzzp84rq4 The User component gets an userId prop passed to it (which changes on button clicks) and pulls that user's name from redux. Currently it gets stuck with data for initial userId and ignores changes.

Am I doing something wrong? Is this by design?

esamattis commented 5 years ago

Yes there were a bug related to this case. I ported your codesandbox example to a test case and made a fix for it.

The fix is now in the 0.1.1 version on npm.

Thanks for reporting!