在React / React Native中使用构造函数与getInitialState有什么区别?

老子叫甜甜 提交于 2020-08-18 05:37:58

问题:

I've seen both used interchangeably. 我看过两者都可以互换使用。

What are the main use cases for both? 两者的主要用例是什么? Are there advantages / disadvantages? 有优点/缺点吗? Is one a better practice? 这是一个更好的做法吗?


解决方案:

参考一: https://stackoom.com/question/24gEQ/在React-React-Native中使用构造函数与getInitialState有什么区别
参考二: https://oldbug.net/q/24gEQ/What-is-the-difference-between-using-constructor-vs-getInitialState-in-React-React-Native
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!