Skip to content

Commit

Permalink
minor style issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanschalm committed Oct 23, 2016
1 parent 9d0d1cc commit 4b69258
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions src/components/ConceptInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class ConceptInput extends Component {
inputValue: ''
}

handleOnKeyPress(e) {
_handleOnKeyPress = e => {
if (e.key === 'Enter' && this.state.inputValue !== '') {
this.setState({
tokens: [...this.state.tokens, this.state.inputValue],
Expand All @@ -17,33 +17,32 @@ class ConceptInput extends Component {
}
}

handleOnChange(e) {
_handleOnChange = e => {
this.setState({inputValue: e.target.value});
}

deleteToken(tokenIndex){
const newState = this.state.tokens;
newState.splice(tokenIndex, 1);
this.setState({tokens: newState})
_deleteToken = tokenIndex => {
const newTokens = this.state.tokens;
newTokens.splice(tokenIndex, 1);
this.setState({tokens: newTokens})
}

render() {
const listItem = this.state.tokens.map((token, index) =>
(
<div key={index}>
{token}
<button onClick={index => this.deleteToken(index)}>Delete Token</button>
</div>
const tokens = this.state.tokens.map((token, index) => (
<div key={index}>
{token}
<button onClick={() => this._deleteToken(index)}>Delete Token</button>
</div>
)
)
);
return (
<div>
<input
type="text"
value={this.state.inputValue}
onKeyPress={this.handleOnKeyPress.bind(this)}
onChange={this.handleOnChange.bind(this)}/>
{listItem}
onKeyPress={this._handleOnKeyPress}
onChange={this._handleOnChange}/>
{tokens}
</div>
);
}
Expand Down

0 comments on commit 4b69258

Please sign in to comment.