Conversation

To drive it home a bit more, I'd add an example of a component that has two different things it's doing in componentDidMount/componentDidUpdate/componentWillUnmount and then separating those things into two separate useEffect calls to show that you can separate concerns too.
2
3
const dimensions = useMemo(getDimensions, [margins]) const xScale = useMemo(getXScale, [data]) const yScale = useMemo(getYScale, [data]) You could do probably just do this: const dimensions = getDimensions() const xScale = getXScale() const yScale = getYScale()
1
1
Unless those functions are computationally expensive. The idea behind useMemo isn't to keep state in sync, but to avoid recalculating things unnecessarily. :)
2
3