I simply try to create a button that chances a state
I have done this many times before but in this cause it just did not do anything
I have tried to code it in different ways and looking on forums and tutorials but could not find he answer
my code:
export class Upload extends Component {
constructor(props) {
super(props);
this.state = {
ShowProduct: false
};
}
ShowView = () => {
this.setState({ ShowProduct: true })
}
render() {
return (
<div id="content-left" style={{ width: this.ShowProduct ? '1%' : '20%' }}></div>
<button id="test" onClick={() => this.ShowView()}>test</button>
)
}
(this is obviously not the full code but the part were the problem is)
when I hit the button it stays on 20% width and nothing happens