Open
Description
Summary
There is a mistake in the ChatRoom example code on the useMemo page, specifically in the 'Preventing an Effect from firing too often' section.
Page
https://react.dev/reference/react/useMemo#preventing-an-effect-from-firing-too-often
Details
There are two mistakes in the ChatRoom example under the 'Preventing an Effect from firing too often' section:
- The line
const options = createOptions()
suddenly appears in the code without context. It seems like this should be removed. - In the comment 'Only changes when createOptions changes', the reference to 'createOptions' should be replaced with 'options object'. This is because options is the actual dependency in the useEffect.