4 ms·
Well, it's only efficient if the component which renders each element in the list gets a stable key AND is React.memo() AND the props passed to the components d
by wereHamster 5y ago
Well, it's only efficient if the component which renders each element in the list gets a stable key AND is React.memo() AND the props passed to the components do not make the React.memo() pointless.
For example the following will not be particularly efficient, because a fresh callback is passed to the component on each render.
<>
{array.map((data) => (
<SomeComponent
data={data}
onClick={() => { alert('nope'); }}
/>
)}
</>
- fabian2k 5y agoThat's what useCallback is for. And it really depends on how heavy the child components are on whether all this makes a noticeable difference.