- Rename React.renderComponent to React.render and use React.createFactory:
was in 0.11:
React.renderComponent(ReactClass(props), container)
should be in 0.12:
React.render(React.createFactory(ReactClass)(props), container) - Use displayName where possible - it will be used in console messages
- Use either JSX or React.createFactory to render children components:
JSX:
var Child = React.createClass(...);
render: function() {
return <Child name={this.props.name} />;
}
JS:
var Child = React.createClass(...);
var factory = React.createFactory(Child);
render: function() {
return factory({name: this.props.name});
} - Do not use transferPropsTo. Use explicit props object in JS code or spread operator in JSX:
JS:
render: function() {
return childFactory(_.extend({}, this.props,
{className: 'name ' + this.props.className});
}
or:
render: function() {
return React.createElement(Child, props);
}
JSX:
render: function() {
return <Child {...this.props} className={'name ' + this.props.className} />;
} - Do not use this.props.key in React class - it is removed from props.
was in 0.11:
var Child = React.createClass({
render: function() {
return <div data-uid={this.props.key} />;
}
});
...
var children = items.map(item => <Child key={item.uid} />);
should be in 0.12:
var Child = React.createClass({
render: function() {
return <div data-uid={this.props.uid} />;
}
});
...
var children = items.map(item => <Child key={item.uid} uid={item.uid} />);
26 нояб. 2014 г.
Upgrade React to 0.12
Подписаться на:
Комментарии к сообщению (Atom)
Комментариев нет:
Отправить комментарий