Button function is not working

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

try

this.state.ShowProduct

it did work I had a small typo, thank you very much :slight_smile:

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.