Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- this.setState({ items: items, itemDetail: items[0], value: this.state.value })
- constructor(props){
- super(props);
- this.state = {
- items: []
- }
- this.handleChange = this.handleChange.bind(this);
- }
- handleChange(event) {
- this.setState({ value: event.target.value });
- }
- componentDidMount(){
- const items = [
- {
- 'id': 0,
- 'name': 'firstName'
- },
- {
- 'id': 1,
- 'name': 'secondName'
- }
- ];
- this.setState({ items: items, itemDetail: items[0] });
- }
- render(){
- const { items, itemDetail } = this.state;
- console.log(itemDetail);
- return(
- <div className="container">
- {itemDetail}
- </div>
- );
- }
Add Comment
Please, Sign In to add comment