2024年4月8日

react-redux与toolkitIndex使用

摘要: 1.安装 React-Redux:首先,你需要将 React-Redux 安装到你的项目中。你可以使用 npm 或者 yarn 来安装它: npm install react-redux 2.创建 Redux Store:在你的应用程序中,创建 Redux store 来管理应用程序的状态。你可以使 阅读全文

posted @ 2024-04-08 22:27 sss大辉 阅读(9) 评论(0) 推荐(0) 编辑

react 性能问题和优化

摘要: 某个组件更新,子组件也会一起更新 react更新采用时间切片,vue则是依赖收集 执行更新操作为16ms,如果操过16ms,先暂停更新,让浏览器先渲染 时间切片时间是16ms,因为人眼刷新率约60帧,60hz为16ms 1.避免state改为同样的值(class用PureComponent,函数组件 阅读全文

posted @ 2024-04-08 22:03 sss大辉 阅读(20) 评论(0) 推荐(0) 编辑

react 函数组件和hook

摘要: 函数组件 1.函数组件没有生命周期 2.函数组件没有this 3.函数组件通过hook完成各种操作 4.函数组件本身就是render函数 5.props在函数第一个参数解释 useState 参考https://www.cnblogs.com/ssszjh/p/14581014.html props 阅读全文

posted @ 2024-04-08 22:01 sss大辉 阅读(18) 评论(0) 推荐(0) 编辑

react ref和context

摘要: ref获取dom context类似provider和injected,用于嵌套很深的爷孙组件传值 子组件使用父组件创建的context对象,不能自己创建 context创建在函数组件和class组件都是一样的 export let Context1 = React.createContext('' 阅读全文

posted @ 2024-04-08 21:57 sss大辉 阅读(12) 评论(0) 推荐(0) 编辑

react 生命周期

摘要: 1.class组件 初次挂载 1.constructor 2.getDerivedStateFromProps 3.render 4.componentDidMount 更新数据 1.getDerivedStateFromProps 2.shouldComponentUpdate 3.render 阅读全文

posted @ 2024-04-08 21:39 sss大辉 阅读(7) 评论(0) 推荐(0) 编辑

导航