DEV Community


Discussion on: React's Odd Obsession With Declarative Syntax

bytebodger profile image
Adam Nathaniel Davis Author • Edited

Your response does raise an interesting thought in my mind about memoization and its use in React. Memoization is powerful and is almost certainly underused. But it's possible that some React devs see this as a (rather lazy) way to chunk everything into the render() process, relying on the memoization (which is another way of saying "cache") to properly sort out when to re-run the algorithm.

And that's all fine-and-good. But if I can choose between

A. Craft a single, imperative function that I know will only run once.
B. Memoize the function, throw it into the render process, and let the React engine figure out on every subsequent re-render whether that function needs to be called again.

I'll almost always choose A.