1const Enter = () => {
2 const handle = () => console.log('Enter pressed');
3
4 return <input type="text" onKeyDown={e => e.key === 'Enter' && handle} />;
5};
1var Input = React.createClass({
2 render: function () {
3 return <input type="text" onKeyDown={this._handleKeyDown} />;
4 },
5 _handleKeyDown: function(e) {
6 if (e.key === 'Enter') {
7 console.log('do validate');
8 }
9 }
10});
11