const render =useCallback(()=>{let list =[]for(var i =0; i < range.max; i++){list.push(<li key={i}>{i}</li>)}return list
},[range])// 第二个参数表依赖项,依赖变化了才会重新渲染const Foo =memo(props =>{console.log('useCallback')return(<><p>{props.count}</p><ul>{props.render()}</ul></>)})
useMemo
固定的是值,会将函数执行
const render =useMemo(()=>{let list =[]for(var i =0; i < range.max; i++){list.push(<li key={i}>{i}</li>)}return list
},[range])// 注意:子组件的render函数不需要执行const Foo =memo(props =>{console.log('useCallback')return(<><p>{props.count}</p><ul>{props.render}</ul></>)})
Code That Writes Code 6.1 Coding your way to the weekend 6.2 Kernel#eval, Binding#eval Binding: Objects of class Binding(类Binding的对象) encapsulate (密封)the execution context at some particular place in the code and retain this c…
(function () { var u navigator.userAgent; var isAndroid u.indexOf(Android) > -1 || u.indexOf(Adr) > -1; //android终端 var isiOS !!u.match(/\(i[^;];( U;)? CPU.Mac OS X/); if(isAndroid){ (function(){ function android_i…