How to close an InlineDialog using a button

Hi!

I’m triggering an InlineDialog from a Byline. In the dialog, I’d like to place a button that simply closes the dialog with this approach:


  const [open, setOpen] = useState(false)

  return (
    <InlineDialog open={open}>
      <Button text='Close' onClick={() => {
        console.log('closing', open);
        setOpen(!open)
        }
      }></Button>
    </InlineDialog>
  );
};

But obviously there is no open attribute on the dialog. Are there any other ways to accomplish this?

Hi @berlund ,

Can you restructure your code to be something like:

const [open, setOpen] = useState(false);
return open ? (
  <InlineDialog>
    <Button text='Close' onClick={() => {
      setOpen(!open)
    }></Button>
  </InlineDialog>
) : null;

Regards,
Dugald

2 Likes

that works (using useState(true)), thanks!

1 Like