Hacker News new | ask | show | jobs
by catlifeonmars 1699 days ago
Makes sense. How about making that the default behavior of React and providing a React.dontMemo(…) API to opt out?
1 comments

Or even better, provide a top level configuration option, like:

ReactDOM.render(element, document.getElementById('root'), {memo: true});

Just dreaming...

This one is interesting, because React has a separation between the renderer and the library. There is a different renderer for e.g. react native, or even for the terminal (!!). It’s a little ambiguous where memoization falls (does it belong to the renderer, or to the core?). I totally agree that being able to switch on behavior for an entire tree or subtree would be ideal, but react tends to use components for that as well (e.g. <React.StrictMode>). Perhaps this should be a component, it could even be implemented via the context system.