This is the point where custom hooks really shine - it’s based on other hooks - let it be other custom hooks or primitive hooks. useSelector will be in my React component and I want to keep the selector function I pass to useSelector inside my redux file, so I can't see how to use closure. Since we do want our code to be DRY and maintainable for the long run, we can abstract away the redux boilercode with custom hooks. In React Redux, when the useSelector() Hook’s reducer action is dispatched, it runs for every mounted component, recalculating the selector with every dispatch and causing performance issues. When the application grows, there may be other components that might be using the same selectors/action creators. Essentially, selectors are functions that take Redux state as an input and return a value derived from that state. However, we can this code even pretier and more useful.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |