Component.eq - Component already includes a very fast, React-compatible object equality thing.. It could be shoe horned into any of the above solutions that use shallow object comparison, to make them even smaller.
And maybe it could be memoized itself, so as not to always have to perform the comparisons..
a memoization addon module
Also see any lightweight and standalone implementations of the useMemo() React hook..
This can be used by users to add memoization to any functions they create or define, such as:
a Components "actions"
any functions the user passes to useState, useEffect, useReducer (etc)
memoization built-in to
Component
I could update Component to (optionally) memoize some of the following functions by default:
Component.setState()
Component.view()
Component.css()
Component.eq()
domDiff
html
andhtmel
render
,useState
,useReducer
,createStore
Ideally, this would be achieved simply by doing:
or for more control:
Possible sources:
Notes:
Component.eq
- Component already includes a very fast, React-compatible object equality thing.. It could be shoe horned into any of the above solutions that use shallow object comparison, to make them even smaller.And maybe it could be memoized itself, so as not to always have to perform the comparisons..
a memoization addon module
Also see any lightweight and standalone implementations of the
useMemo()
React hook..This can be used by users to add memoization to any functions they create or define, such as:
useState
,useEffect
,useReducer
(etc)manually adding caching here & there
Use patterns like this: https://flaviocopes.com/javascript-memoization/