import React from 'react';
import ReactDOM from 'react-dom';
export default class Sidebar extends React.Component {
createDeck(event) {
if(event.which !== 13) return;
var name = 'ReactDOM.findDOMNode(this.refs.add).value';
this.props.addingDeck(name);
this.props.hideAddDeck();
}
render() {
let props = this.props;
return (
<div className="sidebar">
<h2>All Decks</h2>
<button onClick={e => this.props.addingDeck}>
New Deck
</button>
<ul>
{props.decks.map((deck, i) => {
return <li key={i}>{deck.name}</li>
})
}
</ul>
<input ref='add' onKeyPress={e => this.createDeck(e)}/>
</div>
);
}
}
Возможно как-то сделать проще?