1.You must use functional components + hooks + typescript2.Think more: what logic can be extracted for functions /hooks, scenarios3.More thinking: TS type, flexible application, advanced usage4.Functional components must be wrapped in React.memo for optimized performance5.Functions and variables defined in functional components must be implemented using useCallback and useMemo to optimize performance6.In a functional component, define functions, variables, etc., preferentially, can be carried out outside, since functional components re-execute the code in the function every time they render7.UseState must be called as a function, as in:const [count,setCount] = useState(0)/update: setCount(preV= >preV+1)
8.UseEffect Use: Note whether side effects need to be removed when the component is uninstalled9.The hooks, as useEffect useCallback/useMemo etc., to consider all rely on, as long as the use of variable in a function, [] will write rely on outside!!!!!10.
Copy the code