5
當我嘗試和運行Transferring with ... in JSX例如更新後的0.12反應文檔中的語法錯誤?
var FancyCheckbox = React.createClass({
render: function() {
var { checked, ...other } = this.props;
var fancyClass = checked ? 'FancyChecked' : 'FancyUnchecked';
// `other` contains { onClick: console.log } but not the checked property
return (
<div {...other} className={fancyClass} />
);
}
});
React.render(
<FancyCheckbox checked={true} onClick={console.log}>
Hello world!
</FancyCheckbox>,
document.body
);
我得到Uncaught SyntaxError: Unexpected token {
。同樣,當我嘗試運行它在jsfiddle
這是錯誤還是一些額外的代碼transpilation所需的這個工作?