React的 userEffect Hook除了以下功能,还有哪些使用场景呢?

React的 userEffect Hook除了这些功能( 请求数据, 事件处理, 订阅),还有哪些使用场景呢?

阅读 1.5k
1 个回答

在新版本的 React 文档中叙述很详细且有使用示例:

https://beta.reactjs.org/reference/react/useEffect

以下引用自文档:

Usage

  • Connecting to an external system
  • Wrapping Effects in custom Hooks
  • Controlling a non-React widget
  • Fetching data with Effects
  • Specifying reactive dependencies
  • Updating state based on previous state from an Effect
  • Removing unnecessary object dependencies
  • Removing unnecessary function dependencies
  • Reading the latest props and state from an Effect
  • Displaying different content on the server and the client
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题