【发布时间】:2015-11-19 22:04:32
【问题描述】:
我正在从http://teropa.info/blog/2015/09/10/full-stack-redux-tutorial.html 学习 Redux&React。
在代码sn-ps中:
import React from 'react';
import PureRenderMixin from 'react-addons-pure-render-mixin';
import {connect} from 'react-redux';
import Winner from './Winner';
import Vote from './Vote';
export const Voting = React.createClass({
mixins: [PureRenderMixin],
render: function() {
return <div>
{this.props.winner ?
<Winner ref="winner" winner={this.props.winner} /> :
<Vote {...this.props} />}
</div>;
}
});
function mapStateToProps(state) {
return {
pair: state.getIn(['vote', 'pair']),
winner: state.get('winner')
};
}
export const VotingContainer = connect(mapStateToProps)(Voting);
作者正在从“纯”组件创建“有线”反应组件。我对代码中显示的两个“const”关键词有点困惑。我可以理解 javascript 中的 const 值和对象,但是从 OO 的角度来看,const 类对我来说没有意义。
如果我从第一种和/或第二种情况中删除“const”关键字会有什么不同吗?
【问题讨论】:
标签: javascript reactjs redux