_datetimepicker.default.open is not a function
Tencryn opened this issue · comments
I'm getting an error when running DateTimePickerAndroid.open
which is TypeError: _datetimepicker.default.open is not a function (it is undefined), js engine: hermes
Upon looking in the datetimepicker folder within node_modules, I can see that DateTimePickerAndroid.android.js
does contain a definition for open. I'm unsure what I can do to fix this issue.
I am using Expo 49.0.17, with datetimepicker 7.2.0. While datetimepicker is not the latest version, it is the latest that's provided by doing npx expo install @react-native-community/datetimepicker
Dependencies:
"dependencies": {
"@react-navigation/native": "^6.1.9",
"@react-navigation/native-stack": "^6.9.17",
"expo": "~49.0.15",
"expo-status-bar": "~1.6.0",
"react": "18.2.0",
"react-native": "0.72.6",
"react-native-safe-area-context": "4.6.3",
"react-native-screens": "~3.22.0",
"@react-native-community/datetimepicker": "7.2.0"
}
Relevant code:
import DateTimePickerAndroid from '@react-native-community/datetimepicker';
const [time, setTime] = useState(new Date());
const showTimepicker = () => {
DateTimePickerAndroid.open({
value: time,
onChange,
mode: "time",
is24Hour: false,
});
};
Hello 👋🏼 :)
Can you please try to import it like this:
import { DateTimePickerAndroid } from '@react-native-community/datetimepicker';