useSelector hook
See original GitHub issueProposal:
function useSelector(selector) {
const store = React.useContext(StoreContext);
const [state, setState] = React.useState(selector(store.get()));
React.useEffect(() => {
setState(selector(store.get()));
}, [selector]);
store.on('@changed', () => {
setState(selector(store.get()));
})
return state;
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Hooks - React Redux
When an action is dispatched, useSelector() will do a reference comparison of the previous selector result value and the current result value.
Read more >UseSelector and UseDispatch: A Guide to React-Redux Hooks
useSelector and useDispatch are a set of hooks to use as alternatives to the existing connect() higher-order component. The equivalent of map ...
Read more >React-Redux Hooks: useSelector and useDispatch
These Hooks allow you to connect to the Redux store and dispatch actions without having to wrap your components in connect() . This...
Read more >Introduction React-Redux using Hooks (useSelector ...
We will invoke useDispatch and store it to a variable, dispatch . This hook returns a reference to the dispatch function from the...
Read more >React Redux Tutorials - 20 - useSelector Hook - YouTube
React Redux Tutorials - 20 - useSelector Hook. Watch later. Share. Copy link. Info. Shopping. Tap to unmute.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Sorry, but these bindings are important for performance. I do not want to add bad for performance solution.
You can write own custom hook, it is very easy.
I tried it, it is not so convenient.
useStoreon('one', 'two', ... 'ten')
; For example, twenty hooks with this construction…