[Docs]: improve usage of second arg of `useSelector` (equality function)
See original GitHub issueThe documentation talks about using shallowEqual
as second argument for comparison (or lodash), although the documentation doesn’t explain what are the arguments of this function and how a user could write their own custom equality function.
Is there a way to improve that part of the documentation?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:16
- Comments:17 (9 by maintainers)
Top Results From Across the Web
How to pass an additional argument to useSelector
I am calling useSelector successfully from a component, which derives a product name from an id. import { useSelector } from "react-redux"; ...
Read more >Hooks - React Redux
Use a custom equality function as the equalityFn argument to useSelector() , like: import { useSelector } from 'react-redux'
Read more >Redux Gotchas — useSelector - Level Up Coding
This is because the equality check is performed on the outcome of state function. The state property counter is indeed getting updated, which ......
Read more >React-redux useSelector hook and equality checks
useSelector is one of the redux hooks, which really makes life of a dev much more convenient. Usually we use it to get...
Read more >useselector custom hook | The search engine you control.
We can use the useSelector hook to get the data from the Redux store in a React component. It takes 2 arguments. The...
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 FreeTop 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
Top GitHub Comments
@dwaltrip : tbh it’s a trivial enough function that there’s never been a specific need to document it 😃 (Plus in this case you don’t normally call it directly, you just import it and pass it as the second arg to
useSelector
.)But yeah, happy to have a PR!
I understand that
shallowEqual
per se accepts two properties, but when used withuseSelector
, what’s insideleft
andright
?By doing some logging, I can see
left
andright
are the portion of the state selected by the selector.