Home > other >  Programmatically close ant design rangepicker in react
Programmatically close ant design rangepicker in react

Time:12-16

I added a button in the extra footer in the range picker from antd. I wanted to close the range picker when I click the button. Does anyone know how to do this? enter image description here

CodePudding user response:

You can control showing or hiding the picker by using open prop, like this:

const App = () => {
  const [open, setOpen] = React.useState(false);
  return (
    <RangePicker
      open={open}
      onOpenChange={open => setOpen(open)}
      renderExtraFooter={() => <button onClick={()=> setOpen(false)}>Close</button>}
    />
  );
};

I've implemented an example also here.

  • Related