在 reactjs 组件中,我将根据传入的参数计算一个值,该值将永远不会再更改。
说:
React.createClass({
componentWillMount: function() {
this.computedValue = complexComputing(this.props.feed);
},
render: function() {
return <div>{this.computedValue}</div>
}
});
你可以看到我直接把 in 放进去computedValue了this,但我不确定它是不是最好的地方。