摘要:
一、概念 React 性能优化的起因: 在React中,默认情况下,当父组件重渲染时,子组件也会重渲染。 在React中,子组件默认随父组件更新而更新。 React 性能优化的方向:通过缓存,减少渲染次数、减少重复计算。 React Hook性能优化的总结:memo缓存组件、useCallback缓 阅读全文
posted @ 2021-09-30 16:39
starlog
阅读(801)
评论(0)
推荐(0)
摘要:
function unique(arr) { let res = []; for (let i = 0; i < arr.length; i++) { let current = arr[i]; if (res.indexOf(current) -1) res.push(current); } re 阅读全文
posted @ 2021-09-30 14:47
starlog
阅读(31)
评论(0)
推荐(0)
摘要:
class Event { constructor() { // 存储事件的数据结构 // 为了查找迅速,使用了对象(字典) this._cache = {}; } // 绑定 on(type, callback) { // 为了按类查找方便和节省空间, // 将同一类型事件放到一个数组中 // 这 阅读全文
posted @ 2021-09-30 14:27
starlog
阅读(694)
评论(0)
推荐(0)
摘要:
let array = [ { id: 1, name: "001", children: [ { id: 2, name: "002", }, ], }, { id: 3, name: "003", children: [] }, ]; function getFlatArr(arr) { ret 阅读全文
posted @ 2021-09-30 13:46
starlog
阅读(1563)
评论(0)
推荐(1)

浙公网安备 33010602011771号