使用Fountain webapp生成器并使用React + Webpack + ES5 + Gulp创建TODO示例应用程序,并获取源代码:
如何配置Karma和/或Gulp和/或Webpack来分离应用源文件和测试源文件?
(如何将class Button extends React.Component {
props: Props;
state: {
display: 'static' | 'hover' | 'active';
};
static defaultProps: { visited: boolean };
onMouseEnter: () => void;
onMouseLeave: () => void;
onMouseDown: () => void;
constructor(props: Props) {
super(props);
this.state = {
display: 'static',
};
const setDisplay = display => this.setState({display});
this.onMouseEnter = () => setDisplay('hover');
this.onMouseLeave = () => setDisplay('static');
this.onMouseDown = () => setDisplay('active');
}
render() {
let className = 'button ' + this.state.display;
if (this.props.visited) {
className += ' visited';
}
return (
<div className={className}
onMouseEnter={this.onMouseEnter}
onMouseLeave={this.onMouseLeave}
onMouseDown={this.onMouseDown}
onClick={this.props.onClick}>
{this.props.title}
</div>
);
}
}
与*.js
分开?)