2 ms·
Also useful in react. It's better to use `data-props` for performance, but if somehow `data-` props cannot contain the information (function maybe), you can use
by fendy3002 5y ago
Also useful in react. It's better to use `data-props` for performance, but if somehow `data-` props cannot contain the information (function maybe), you can use currying with previously memoize it first.
For example, if you want to pass an object to onClick event:
const handleOnClick = _.memoize(
(myObj) =>
(evt) => {
// you can do something with myObj here
});
// on render
return <button onClick={handleOnClick(myObj)} >Try it</button>;
Memoize works on class component but I don't know if it works on function component.