I have a problem with this code, my Toggle button doesn't display the Child element but gives me a full blank page Here is the code
class App extends React.Component {
constructor(props, context) {
super(props, context);
this.state = {items: [] , isHidden: true};
this.toggleHidden = this.toggleHidden.bind(this);
}
componentDidMount() {
fetch("/customers")
.then(result=>result.json())
.then(items=>this.setState({items}));
}
toggleHidden () {
this.setState({
isHidden: !this.state.isHidden
});
}
render() {
return (
<div id='customerDetails'>
{this.state.items.map(item=><customerDetail>
<div id={item._id} >
<button onClick={this.toggleHidden} data-arg1={item._id} value='U'/>
{item.cost}
{!this.state.isHidden && <Child >
<div className='modal'>
<form onSubmit={this._handleUpdate}>
<input type='text' id='cost' name='cost'/>
<input type='hidden' id="_id" name='_id' value=item.id />
<input type='submit' value='Update'/>
</form>
</div>
</Child>
}
</div>
</customerDetail>)}
</div>
);
}
}
Any idea , i do not know if it's coming from the fact all that happens in an iteration I also tried this standalone source code from StackOverflow React toggle component that should work, and it does not work....blank page
Any idea
Thanks