You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm getting an error saying that the value prop must be an instance of the date. I'm confused because it is???
`import { StyleSheet, Text, View } from 'react-native'
import React, {useState} from 'react'
import DateTimePicker from '@react-native-community/datetimepicker';
const setup = () => {
//6 AM original time
const initialTime = new Date();
initialTime.setHours(9);
initialTime.setMinutes(30);
const [time, setTime] = useState(initialTime);
const onChange=(selectedTime)=>{
const actualTime = selectedTime || initialTime; //in case the user wants the default time,
setTime(actualTime);
}
return (
<View>
<Text>Setup</Text>
<Text>What time do you want to be notified to set your 3 priorities for the day?</Text>
<DateTimePicker
testID="dateTimePicker"
value={time}
mode="time"
display="default"
onChange={onChange}
/>
</View>
)
}
export default setup
const styles = StyleSheet.create({})`
The text was updated successfully, but these errors were encountered:
Your time state is not a date instance, you should change onChange function because you are setting time state as a native event instead of Date instance. Change the onChange function to be like the following.
const onChange=(event, selectedTime)=>{
const actualTime = selectedTime || initialTime; //in case the user wants the default time,
setTime(actualTime);
}
Question
I'm getting an error saying that the value prop must be an instance of the date. I'm confused because it is???
`import { StyleSheet, Text, View } from 'react-native'
import React, {useState} from 'react'
import DateTimePicker from '@react-native-community/datetimepicker';
const setup = () => {
//6 AM original time
const initialTime = new Date();
initialTime.setHours(9);
initialTime.setMinutes(30);
return (
)
}
export default setup
const styles = StyleSheet.create({})`
The text was updated successfully, but these errors were encountered: