Closed as not planned
Description
Prerequisites
- I have read the Contributing Guidelines.
- I agree to follow the Code of Conduct.
- I have searched for existing issues that already report this problem, without success.
Ionic Framework Version
- v4.x
- v5.x
- v6.x
Current Behavior
The component IonDatetime
is not updating the UI changing the value. The value is handled by a state variable (useState
).
This is only not working, if the presentation is set to month-year
or year
.
Expected Behavior
If the state variable changes, the component should update the UI.
Steps to Reproduce
function Example() {
const [date, setDate] = useState(new Date().toISOString())
const handleClick= () => {
setDate((d) => {
const year = new Date(d).getFullYear();
const newDate = new Date(d);
newDate.setFullYear(year + 1);
return newDate.toISOString();
});
}
return (
<>
<IonButton onClick={handleClick} >Click</IonButton>
<IonDatetime presentation="year" value={date} />
</>
)
}
Code Reproduction URL
https://codesandbox.io/s/cool-fog-u3by0v?file=/src/App.js
Ionic Info
Ionic:
Ionic CLI : 6.17.1 (/usr/local/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/react 6.0.11
Capacitor:
Capacitor CLI : 3.4.0
@capacitor/android : 3.4.1
@capacitor/core : 3.4.1
@capacitor/ios : 3.4.1
Utility:
cordova-res : not installed globally
native-run : 1.5.0
System:
NodeJS : v16.14.0 (/Users/timwerner/.nvm/versions/node/v16.14.0/bin/node)
npm : 8.3.1
OS : macOS Monterey
Additional Information
No response