current position:Home>React setstate and hooks

React setstate and hooks

2021-08-23 04:29:55 snowofcat

1.  Function component 
const [state, setState] = useState('');
setState The essence :dispatchAction -> scheduleUpdateOnFiber

2. class Components 
this.setState({}) -> enqueueSetState -> scheduleUpdateOnFiber
setState yes Component.prototype The method on the ,constructClassInstance -> adoptClassInstance -> instance.update = classComponentUpdater

copyright notice
author[snowofcat],Please bring the original link to reprint, thank you.

Random recommended