简体   繁体   English

v0.13.3中的React.js复选框示例?

[英]React.js checkbox example in v0.13.3?

Brand new to React (looked up on wikipedia two days ago) so downloaded current version v0.13.3 from home page. React的全新功能(两天前在Wikipedia上进行了查询),因此从主页下载了当前版本v0.13.3。 Trying to find a checkbox example (check a box, something happens - like a label appears or something). 试图找到一个复选框示例(选中一个复选框,发生了某些事情-如出现标签之类的东西)。 This one works in JSFIDDLE . 这在JSFIDDLE有效 Discovering with much frustration that that things are often deprecated on new releases of React, so older examples don't work anymore. 沮丧地发现新版本的React通常不推荐使用这些东西,因此旧的示例不再起作用。 On this one, the browser says 在这一页上,浏览器说

Uncaught TypeError: Cannot read property '__reactAutoBindMap' of undefined`)

which is not even in the code. 这甚至不在代码中。 Looked at bunches of articles, tried bunches of things like 看了一堆文章,尝试了一堆东西

React.renderComponent → React.render

Anyone know the magic tricks required to make this example work with the current version of v0.13.3? 有人知道使此示例与当前版本的v0.13.3配合使用所需的魔术吗?

Or anyone know of a working checkbox example in v0.13.3? 还是有人知道v0.13.3中有效的复选框示例?

Thanks. 谢谢。

The error is in the rendering of the element. 错误在于元素的呈现。

React.renderComponent(
    CrossoutCheckbox({text: "Text Text", complete: false}),document.body
);

The right syntax, if you don't want to use JSX is the following: 如果您不想使用JSX,则正确的语法如下:

React.render(
    React.createElement(
        CrossoutCheckbox, {text: "Test text", complete: false}),
        document.body);

The direct creation of an element was removed in the 0.13.0, as you can read in the change log https://github.com/facebook/react/blob/master/CHANGELOG.md 您可以在更改日志https://github.com/facebook/react/blob/master/CHANGELOG.md中读取该内容,而在0.13.0中删除了直接创建元素的功能。

Deprecated patterns that warned in 0.12 no longer work: most prominently, calling component classes without using JSX or React.createElement and using non-component functions with JSX or createElement 在0.12中发出警告的不推荐使用的模式不再起作用:最显着的是,不使用JSX或React.createElement以及不使用JSX或createElement的非组件函数来调用组件类

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM