我在这里找到了一个关于这个问题的jsbin:http://jsbin.com/tekuluve/1/edit
在onClick事件中,我正在从模型中删除元素,并重新呈现应用程序.但奇怪的是,在componentWillReceiveProps()(以及componentWillUpdate和componentDidUpdate)中,无论我做什么,nextProps总是===到this.props.
/** @jsx React.DOM */
var Box = React.createClass({
render: function() {
return (
<div className="box" onClick={ UpdateModel }>
{ this.props.label }
</div>
);
}
});
var Grid = React.createClass({
componentWillReceiveProps: function(nextProps) {
// WTF is going on here???
console.log(nextProps.boxes === this.props.boxes)
},
render: function() {
var boxes = _.map(this.props.boxes, function(d) {
return (<Box label={ d.number } />);
});
return (
<div className="grid">
{ boxes }
</div>
);
}
});
var model = [
{ number: 1 …Run Code Online (Sandbox Code Playgroud) 我正在为我的组件使用React,并且为了用我的组件打包样式,我按照文档化的webpack方法要求它们:
require('./style.css');
但是当我尝试在服务器上渲染时,node-jsx会抛出错误当它试图改变css.有没有另一种转换jsx的方法,它不会破坏css?我宁愿不把样式分解成自己的管道,因为这会很好地破坏webpack包装组件的优势.