Skip to content

Instantly share code, notes, and snippets.

@Nikola-Andreev
Created December 1, 2016 12:46
Show Gist options
  • Save Nikola-Andreev/8b268203e69d9354bf09c13c38e3ca4b to your computer and use it in GitHub Desktop.
Save Nikola-Andreev/8b268203e69d9354bf09c13c38e3ca4b to your computer and use it in GitHub Desktop.
function listTowns(selector) {
let ListTowns = React.createClass ({
getInitialState: function() {
return { listItems: [] }
},
fill:function () {
let values = $('.values').val().split(', ')
this.setState({
listItems: values.map((str)=> {
return <li>{str}</li>
})
})
},
render: function() {
return (
<div>
<form>
<input className="values" type="text"/>
<input type="button" value="submit" onClick={this.fill}/>
</form>
<ul>{this.state.listItems}</ul>
</div>
)
}
})
ReactDOM.render(
<ListTowns listItems={[]}/>,
document.getElementById(selector)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment