Demo: http://codepen.io/suin/pen/EjpBgK
const words = ["進捗", "どう", "です", "か"];
class Shinchokudodesuka extends React.Component {
constructor(props) {
super(props);
this.state = {message: "", done: false};
}
componentDidMount() {
this.dodesuka();
}
componentDidUpdate() {
this.dodesuka();
}
dodesuka() {
if (this.state.done === false) {
setTimeout(() => {
const nextMessage = this.state.message + words[Math.floor(Math.random()*words.length)];
this.setState({message: nextMessage, done: /進捗どうですか$/.test(nextMessage)});
}, 10);
}
}
render() {
return (
<div>
{this.state.message}
{this.state.done ? <span>???<br/>{this.state.message.length}文字で煽られました。</span> : ""}
</div>
);
}
}
React.render(
<Shinchokudodesuka/>,
document.getElementById('example')
);
-
[進捗どうですかブーム???にShellScriptで挑むフリしてExpectに逃げる]
(http://qiita.com/mpyw/items/e5a93e7195d8a8284a1f)