Skip to content

Commit

Permalink
Fix not working moment example (#1353)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmtrKovalenko authored Oct 14, 2019
1 parent 200cf28 commit e8ad333
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions docs/pages/localization/Moment.example.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import moment from 'moment';
import MomentUtils from '@date-io/moment';
import MoreIcon from '@material-ui/icons/MoreVert';
import React, { useState, useCallback } from 'react';
import { IconButton, Menu, MenuItem } from '@material-ui/core';
import { DatePicker, MuiPickersUtilsProvider } from '@material-ui/pickers';

import 'moment/locale/fr';
import 'moment/locale/ru';

moment.locale('fr'); // it is required to select default locale manually

const localeMap = {
en: 'en',
fr: 'fr',
Expand All @@ -24,15 +26,17 @@ function MomentLocalizationExample() {
}, []);

const selectLocale = useCallback(locale => {
moment.locale(locale);

setLocale(locale);
setAnchorEl(null);
}, []);

return (
<MuiPickersUtilsProvider utils={MomentUtils} locale={locale}>
<MuiPickersUtilsProvider libInstance={moment} utils={MomentUtils} locale={locale}>
<DatePicker
value={selectedDate}
onChange={handleDateChange}
onChange={date => handleDateChange(date)}
InputProps={{
endAdornment: (
<IconButton
Expand Down

0 comments on commit e8ad333

Please sign in to comment.