Is there a way to close a previously opened instance of @react-native-community/datetimepicker?
I'd like to close it in componentWillUnmount or using setTimeout or some other event. Unfortunately, even if the component is removed, the native picker stays open.
I tried something like this:
function example() {
  const [showPicker, setShowPicker] = useState(false);
  setTimeout(() => {
    setShowPicker(!showPicker);
  }, 5000);
  return (
    <>
      {showPicker && (
        <DateTimePicker mode="date" value={new Date()} />
      )}
    </>
  );
}
This makes the picker open every 10 seconds but it needs to be closed manually. Is there any way to close it directly from the code (not by the user)?
 
     
    