title: React Native datetimepicker re-renders back to default value
body: <p>I am trying to implement this <a href="https://github.com/react-native-datetimepicker/datetimepicker/issues/182" rel="nofollow noreferrer">solution found here</a> but I am running into the following error. <code>Error: rendered more hooks than during the previous render</code></p>
  <p>Here is my code. What am I missing? Am I implementing the solution correctly?</p>
  <pre><code>export default function Foo(){
  const [showCalendar, setShowCalendar] = useState(false);
  
     function fooA(newDate){
        onChange(newDate)// function that updates date, works on ios. I do not think its the issue.
      setShowCalendar(false)
  
     }
  
     function fooB(){
       {React.useMemo(() =&gt; {
          return (
            &lt;RNDateTimePicker 
              onChange={fooA(newDate)} 
              value={date} 
              display='spinner' 
              {...rest} 
            /&gt;
          )
        }, [showCalendar])}
     }
  
     return (
        &lt;TouchableOpacity onPress={() =&gt; setShowCalendar(true)}&gt;
          fooB()
        &lt;/TouchableOpacity&gt;
     )
  }
  
  </code></pre>