Skip to content

Commit 2ca548e

Browse files
asudohjoshblack
authored andcommitted
fix(date-picker): support changing date format (carbon-design-system#4856)
This change allows change in `dateFormat` prop after initialization reflected correctly to the underlying Flatpickr.
1 parent ed99969 commit 2ca548e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

packages/react/src/components/DatePicker/DatePicker.js

+7
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,13 @@ export default class DatePicker extends Component {
383383
}
384384
}
385385

386+
componentDidUpdate({ dateFormat: prevDateFormat }) {
387+
const { dateFormat } = this.props;
388+
if (this.cal && prevDateFormat !== dateFormat) {
389+
this.cal.set({ dateFormat });
390+
}
391+
}
392+
386393
componentWillUnmount() {
387394
if (this.cal) {
388395
this.cal.destroy();

0 commit comments

Comments
 (0)