在新版本的 React 文档中叙述很详细且有使用示例:https://beta.reactjs.org/reference/react/useEffect以下引用自文档:UsageConnecting to an external systemWrapping Effects in custom HooksControlling a non-React widgetFetching data with EffectsSpecifying reactive dependenciesUpdating state based on previous state from an EffectRemoving unnecessary object dependenciesRemoving unnecessary function dependenciesReading the latest props and state from an EffectDisplaying different content on the server and the client
在新版本的 React 文档中叙述很详细且有使用示例:
https://beta.reactjs.org/reference/react/useEffect
以下引用自文档: