<>hooks The role of

*
It changed the original React How to develop classes , Function form was used instead ; It changes the complex form of state operation , Make it easier for programmers to use ; It changes the reusability of a state component , Greatly increase the reusability of components .
<>useState
// Declaration status const [ count , setCount ] = useState(0); // Usage status <p>You clicked
{count} times</p> <button onClick={()=>{setCount(count+1)}}>click me</button>
<>useEffect

<> One parameter
useEffect(()=>{ console.log(" First render and update ") })
* simulation :
componentDidMount componentDidUpdate
<> A parameter band return
useEffect(()=>{ console.log(" First render and update ") return ()=>{console.log( First uninstall )} })
* simulation :
componentDidMount
componentDidUpdate
* return
componetWillUnmount
componentDidUpdate
<> The second parameter is an empty array ,return
useEffect(()=>{ console.log(" First render and update ") return ()=>{console.log( First uninstall )} },[])
* Relative to life cycle componentDidMount and componetWillUnmount
<> The second parameter is the specific value
useEffect(()=>{ console.log(" First render and update ") return ()=>{console.log( First uninstall )} },[num])
*
simulation
componentDidMount
componentDidUpdate(update Only right num Useful )

*
return
componetWillUnmount
componentDidUpdate(update Only right num Useful )

<>useRef
const inp = useRef(null) <input ref={inp}> // call inp.current.value
<> custom hook

*
definition :const [size,setSize] = useState({height:xxx,width:xxx})

*
handle :
const onResize = ()=>{setSize({width:xxx,height:xxx})}
useEffect(()=>{
Monitoring events window.addEventListener(“resize”,onResize)
return Remove listening ()=>window.removeEventListener(“resize”,onResize)
},[])

*
return return size

*
use const size = useWinSize()

Technology
©2020 ioDraw All rights reserved
synchronized Fair lock or unfair lock R language | Processing method of missing value —— multiple imputation : utilize mice() package @ControllerAdvice Intercept abnormal return data GitHub HR supervisor resigns due to dismissal of Jewish employee python Basic exercises ( One )Can not deserialize instance of java.util.ArrayList out of VALUE_TRUE tokenpytorch torchvision.transforms.Normalize() In mean and std parameter --- Dispelling doubts NVIDIA-SMI has failed because it couldn’t communicate with the NVIDIA driver. First order low pass filter - Continuous to discrete Sources said Alibaba will cancel “361” system No coercion 10% No year-end bonus for employees