TypeError: value.getTime is not a function. (In 'value.getTime()', 'value.getTime' is undefined)
See original GitHub issue👋 Hi!
Summary
You cant use the DateTimePicker with expo. When I try to open the Picker it crashes the App. I am using a Component.
Reproducible sample code
class Main extends Component {
state = {
activityDate: new Date(),
showPicker: false,
pickerValue: ""
}
render(){
return(
<View style={styles.container}>
<Button
title="Open"
onPress={() => this.setState({
showPicker: true
})}
/>
<View>
{ this.state.showPicker && (
<DateTimePicker
value={this.state.showPicker}
mode={"date"}
onChange={
(date) => {
this.setState({
activityDate: date,
showPicker: false
})
}
}
/>
)}
</View>
</View>
)
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
// alignItems: 'center',
justifyContent: 'center',
},
});
export default Main;
Steps to reproduce
- Start a new Expo Project
- Run the project with expo start or expo run:android - both fails
- Try to use the DateTimePicker - open it up with a Button click
- Basically thats it …
Describe what you expected to happen:
- The App crashes with the following:
- TypeError: value.getTime is not a function. (In ‘value.getTime()’, ‘value.getTime’ is undefined)
This error is located at: in RNDateTimePicker (created by Main) in RCTView (created by View) in View (created by Main) in RCTView (created by View) in View (created by Main) in Main (created by App) in App (created by ExpoRoot) in ExpoRoot in RCTView (created by View) in View (created by AppContainer) in RCTView (created by View) in View (created by AppContainer) in AppContainer at node_modules\react-native\Libraries\LogBox\LogBox.js:149:8 in registerError at node_modules\react-native\Libraries\LogBox\LogBox.js:60:8 in errorImpl at node_modules\react-native\Libraries\LogBox\LogBox.js:34:4 in console.error at node_modules\expo\build\environment\react-native-logs.fx.js:27:4 in error at node_modules\react-native\Libraries\Core\ExceptionsManager.js:104:6 in reportException at node_modules\react-native\Libraries\Core\ExceptionsManager.js:172:19 in handleException at node_modules\react-native\Libraries\Core\ReactFiberErrorDialog.js:43:2 in showErrorDialog at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:15792:34 in logCapturedError at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:15884:20 in update.callback at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:7199:2 in callCallback at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:7220:20 in commitUpdateQueue at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:16632:25 in commitLifeCycles at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:19216:22 in commitLayoutEffects at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:93:4 in invokeGuardedCallbackProd at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:318:2 in invokeGuardedCallback at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:18952:29 in commitRootImpl at node_modules\scheduler\cjs\scheduler.development.js:468:23 in unstable_runWithPriority at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:18791:17 in commitRoot at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:18192:12 in performSyncWorkOnRoot at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:5911:33 in runWithPriority$argument_1 at node_modules\scheduler\cjs\scheduler.development.js:468:23 in unstable_runWithPriority at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:5906:23 in flushSyncCallbackQueueImpl at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:5893:28 in flushSyncCallbackQueue at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:18211:28 in batchedUpdates$1 at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:2534:29 in batchedUpdates at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:2680:16 in _receiveRootNodeIDEvent at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:2800:27 in receiveTouches at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:414:4 in __callFunction at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:113:6 in __guard$argument_0 at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:365:10 in __guard at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:112:4 in callFunctionReturnFlushedQueue
TypeError: value.getTime is not a function. (In ‘value.getTime()’, ‘value.getTime’ is undefined)
This error is located at: in RNDateTimePicker (created by Main) in RCTView (created by View) in View (created by Main) in RCTView (created by View) in View (created by Main) in Main (created by App) in App (created by ExpoRoot) in ExpoRoot in RCTView (created by View) in View (created by AppContainer) in RCTView (created by View) in View (created by AppContainer) in AppContainer at node_modules\react-native\Libraries\LogBox\LogBox.js:149:8 in registerError at node_modules\react-native\Libraries\LogBox\LogBox.js:60:8 in errorImpl at node_modules\react-native\Libraries\LogBox\LogBox.js:34:4 in console.error at node_modules\expo\build\environment\react-native-logs.fx.js:27:4 in error at node_modules\react-native\Libraries\Core\ExceptionsManager.js:104:6 in reportException at node_modules\react-native\Libraries\Core\ExceptionsManager.js:172:19 in handleException at node_modules\react-native\Libraries\Core\setUpErrorHandling.js:24:6 in handleError at node_modules\expo-dev-launcher\build\DevLauncherErrorManager.js:44:19 in errorHandler at node_modules\expo-dev-launcher\build\DevLauncherErrorManager.js:49:24 in <anonymous> at node_modules\expo-error-recovery\build\ErrorRecovery.fx.js:12:21 in ErrorUtils.setGlobalHandler$argument_0 at node_modules\regenerator-runtime\runtime.js:63:36 in tryCatch at node_modules\regenerator-runtime\runtime.js:294:29 in invoke at node_modules\regenerator-runtime\runtime.js:63:36 in tryCatch at node_modules\regenerator-runtime\runtime.js:155:27 in invoke at node_modules\regenerator-runtime\runtime.js:165:18 in PromiseImpl.resolve.then$argument_0 at node_modules\react-native\node_modules\promise\setimmediate\core.js:37:13 in tryCallOne at node_modules\react-native\node_modules\promise\setimmediate\core.js:123:24 in setImmediate$argument_0 at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:123:14 in _callTimer at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:177:14 in _callImmediatesPass at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:437:30 in callImmediates at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:388:6 in __callImmediates at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:132:6 in __guard$argument_0 at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:365:10 in __guard at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:131:4 in flushedQueue
Environment info
Expo Diagnostic Output:
Expo CLI 5.2.0 environment info:
System:
OS: Windows 10 10.0.19043
Binaries:
Node: 14.17.4 - C:\Program Files\nodejs\node.EXE
npm: 7.20.5 - C:\Dev\npm\npm\npm.CMD
IDEs:
Android Studio: Version 2021.1.0.0 AI-211.7628.21.2111.8139111
npmPackages:
expo: ~44.0.0 => 44.0.6
react: 17.0.1 => 17.0.1
react-dom: 17.0.1 => 17.0.1
react-native: 0.64.3 => 0.64.3
react-native-web: 0.17.1 => 0.17.1
Expo Workflow: bare
npx react-native info
output:
System:
OS: Windows 10 10.0.19043
CPU: (6) x64 Intel(R) Core(TM) i5-8400 CPU @ 2.80GHz
Memory: 4.23 GB / 15.94 GB
Binaries:
Node: 14.17.4 - C:\Program Files\nodejs\node.EXE
Yarn: Not Found
npm: 7.20.5 - C:\Dev\npm\npm\npm.CMD
Watchman: Not Found
SDKs:
Android SDK: Not Found
Windows SDK: Not Found
IDEs:
Android Studio: Version 2021.1.0.0 AI-211.7628.21.2111.8139111
Visual Studio: Not Found
Languages:
Java: 1.8.0_281 - C:\Program Files\Java\jdk1.8.0_281\bin\javac.EXE
npmPackages:
@react-native-community/cli: Not Found
react: 17.0.1 => 17.0.1
react-native: 0.64.3 => 0.64.3
react-native-windows: Not Found
npmGlobalPackages:
*react-native*: Not Found
datetimepicker version: “@react-native-community/datetimepicker”: “4.0.0”
iOS / Android version: Android 10
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (1 by maintainers)
Top GitHub Comments
It does not like new Date() it expects a ISO date but casting new Date toISOString() looks fine.
@Salmankhan033 Thanks, this works!
Still something that is missing is, when I set the Date it works - but opening the Picker again selects the day from today even though the new value is a state that should already be changed by the onChange Function.