Skip to content

Commit

Permalink
fix(date-picker): support changing date format (#4856)
Browse files Browse the repository at this point in the history
This change allows change in `dateFormat` prop after initialization
reflected correctly to the underlying Flatpickr.
  • Loading branch information
asudoh authored and joshblack committed Jan 13, 2020
1 parent 4ca6a2d commit c168321
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/react/src/components/DatePicker/DatePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,13 @@ export default class DatePicker extends Component {
}
}

componentDidUpdate({ dateFormat: prevDateFormat }) {
const { dateFormat } = this.props;
if (this.cal && prevDateFormat !== dateFormat) {
this.cal.set({ dateFormat });
}
}

componentWillUnmount() {
if (this.cal) {
this.cal.destroy();
Expand Down

0 comments on commit c168321

Please sign in to comment.