// performance optimization point, very little into multiple, web pages will become the favored manufacturers
// as a function hooks
React Import, useState {} from 'REACT'; // Import from ToDoList './TodoList'; function the App () { the let A =. 1; the console.log (. 1) // update data can be seen, once executed, let a be performed above, when more data loss performance. const [b, setb] = useState (a); // hooks destructuring assignment return ( <className = div "the App"> {B} <= {Button the onClick () => {SETB (B +. 1)}}> < / Button> </ div> ); } Export default the App;
// can be used in the following manner
React Import, useState {} from 'REACT'; // Import from ToDoList './TodoList'; function the App () { // the console.log (. 1) const [B, SETB] = useState (() => { the let =. 1 A; the console.log (A); // you can see this way, only the first data initialized when high data efficiency performance. return A; }); return ( <className = div " the App "> {B} <= {Button the onClick () => {SETB (B +. 1)}}> </ Button> </ div> ); } Export default the App;