语法糖 VS 性能

2018-01-01 19:18:14 +08:00
 dxcqcv

转向 vue 后,又学习下 react16,

一开始我以为 React 16 会完全移除createClass方法,没想到只是换个名字,而且连在 react15 中的不推荐也移除了,

The deprecations introduced in 15.x have been removed from the core package. React.createClass is now available as create-react-class, React.PropTypes as prop-types, React.DOM as react-dom-factories, react-addons-test-utils as react-dom/test-utils, and shallow renderer as react-test-renderer/shallow. See 15.5.0 and 15.6.0 blog posts for instructions on migrating code and automated codemods.

本来还担心为了一点点的性能每次都去bind好麻烦,现在直接用createReactClass也是一样

那么现在 react 开发中,大家喜欢class还是createReactClass

2399 次点击
所在节点    React
2 条回复
crysislinux
2018-01-01 20:42:34 +08:00
这个迁移跟性能没关系,是因为有 class 的标准了就往 class 靠。原来那种方式还是会 bind,只不过是框架帮你做了
Kilerd
2018-01-01 21:44:31 +08:00
autobind_decorator

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/419179

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX