Skip to content

React 面试题3

仲灏2022-07-04约 1 分钟

react-router 如何配置懒加载

image-20220704182414041

PureComponent 有何区别

  • 实现了浅比较的 shouldComponentupdate
  • 优化性能
  • 但要结合不可变值使用

React 事件和 DOM 事件的区别

  • 所有事件挂载到 document 上 (17以后挂在在root组件上)
  • event 不是原生的,是 SyntheticEvent 合成事件对象
  • dispatchEvent

React 性能优化

  • 渲染列表时加 key
  • 自定义事件、DOM 事件及时销毁
  • 合理使用异步组件
  • 减少函数 bind this 的次数
  • 合理使用 SCU PureComponent 和 memo
  • 合理使用 Immutable.js