Our great sponsors
-
use-deep-compare-effect
🐋 It's react's useEffect hook, except using deep comparison on the inputs, not reference equality
-
SurveyJS
Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
Unfortunately useMemo does not accept a second comparison argument like React.memo. If you want to do a deep comparison there are several code samples and libraries out there you can use.
Caching computed values in class components is a bit clunkier, especially if you are trying to avoid the UNSAFE_componentWillReceiveProps() lifecycle function. The React maintainers recommend using the memoize-one library:
You can leverage libraries like react-virtualized or react-window to handle this for you.
You can leverage libraries like react-virtualized or react-window to handle this for you.
Related posts
- Thoughts on this Timeline design I've been working on?
- How to render a component only when it's in the viewport?
- Effectively rendering lists using the `useMemo` hook in React.js
- 7 React optimization techniques you should know
- How to implement a React infinite scroll component for a chat app like Facebook Messenger?