react class 和hook混用

 

原文鏈接: react class 和hook混用

上一篇: regl-camera-ts 重構 regl的3d相機庫

下一篇: 試試光追

詳細參考這個

https://www.zoo.team/article/react-hooks-in-class-component

遇到這個錯誤

×
Error: Objects are not valid as a React child (found: object with keys {count}). If you meant to render a collection of children, use an array instead.

應該使用單花括號!!!!

我的場景比較簡單, 長時間不寫, 都不會寫fc了...和vue混着來了

 pnpx create-react-app react-ts --template typescript

基本思路就是透傳屬性, class中使用state, 然後fc中用屬性, 這樣能避免修改代碼

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章