3 ms·
You can largely avoid useMemo by keeping your props and state in the format you actually need them. The solution for more complex useMemo and useCallback usage
by harrisonjackson 4y ago
You can largely avoid useMemo by keeping your props and state in the format you actually need them.
The solution for more complex useMemo and useCallback usage is to create your own hooks.
You can compose all the hooks into a single hook that your component uses and return from that hook whatever your component needs. This is common with components that have a lot of event listeners that can trigger local state and/or redux state changes.
We have a spreadsheet component and the individual cells had some pretty gnarly hooks and after pulling them into their own custom hook we've been able to maintain them nicely.