0

I want to click a button to show a popup without using state and without using hooks. I am currently using 'antd' as my graphics library but any solution that works can be adapted for my needs.

The button comes from a return of a function:

public getButton()
{
    return <Button onClick={()=>???} >Yes</Button>
}

The onClick should generate a Modal (ideally).

Thanks.

  • "without using state and without using hooks" -- why use react if you don't want to use it the way it was meant to be used? – Christian Fritz Dec 04 '20 at 03:55
  • I can't use state because I don't have a React.Component and I can't use hooks because my component is not a function component. I can modify it to be a React.Component but I was just curious if it was possible without doing so. –  Dec 06 '20 at 01:58

1 Answers1

0

Instead of storing it in a state, use this variable like this.showModal to store the boolean value and use it for showing modal.

  • Will not work because you would have to use this.setState() or this.forceUpdate() to refresh the component, neither of which I can use (no state and no hooks). –  Dec 06 '20 at 01:54