Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

Type error when using controlled datetime picker

$
0
0

How do I set a react state with a event.target.value in a datetime picker?

Here is my code that is not working:

const [ date, setDate ] = useState(new Date());<input type="datetime-local" className="form-control" onChange={event => setDate(event.target.value)} value={date}/>   

Here is the error that shows me:

Argument of type 'string' is not assignable to parameter of type 'SetStateAction'.ts(2345)

Do you know how can I fix this?


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>