Android: Picker does not show correctly when the mode prop changes
See original GitHub issueDescribe the bug
On Android, when the mode
prop changes, the UI shows a blank space with only the separator.
Expected behavior
When the mode
prop changes, the UI should show the correct picker for that mode
.
Screenshots
In the video below, the switch toggles the mode
prop between "date"
and "datetime"
. The initial value for mode
is “date”, which shows correctly. But when the mode prop is changed to "datetime"
, it shows blank.
https://user-images.githubusercontent.com/4929170/138826099-26e774f8-e0e3-44bc-86e4-3a4a00229435.mp4
To Reproduce Add example code that reproduces the behavior.
export default class App extends Component {
state = { date: new Date(), mode: "date"}
render = () =>
<View>
<Button title="Toggle" onPress={() => {
if (this.state.mode === "date") {
this.setState({ mode: "datetime" })
} else {
this.setState({ mode: "date" })
}
}} />
<DatePicker
mode={this.state.mode}
date={this.state.date}
onDateChange={date => this.setState({ date })}
/>
<View>
}
Smartphone (please complete the following information):
- OS: Android
- React Native version: 0.63.4
- react-native-date-picker version: 4.1.1
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
React Native Picker: onValueChange triggers unintended ...
The state variable changes to the desired dropdown item for one render iteration and then automatically resets to the defaultPlaceholder value.
Read more >react-native-community/datetimepicker - npm
Defines the maximum date that can be selected. Note that on Android, this only works for date mode because TimePicker does not support...
Read more ><input type="color"> - HTML: HyperText Markup Language
The change event is fired when the user dismisses the color picker. In both cases, you can determine the new value of the...
Read more ><activity> | Android Developers
All activities must be represented by {@code } elements in the manifest file. Any that are not declared there will not be seen...
Read more >Notifications - Expo Documentation
This prompt will not appear until at least one notification channel is created ... app with eas build -p android or npx expo...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Try using
textColor
property and set it to black explicitly, that worked on Pixel 6 Pro.This fixes the issue if the phone is using dark mode, since the datepicker seems to use a white font when the phone is in dark mode, making it appear as if the datepicker is blank.