SHARE
TWEET

Untitled

a guest Aug 24th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import {withStyles} from '@material-ui/core/styles';
  4.  
  5. import MomentUtils from '@date-io/moment';
  6. import {MuiPickersUtilsProvider, KeyboardDatePicker} from '@material-ui/pickers';
  7.  
  8. const styles = {};
  9.  
  10. class DatePickerWrapper extends React.Component {
  11.   constructor(props) {
  12.     super();
  13.  
  14.     this.label = props.label;
  15.  
  16.     this.state = {
  17.       date: props.date
  18.     };
  19.   }
  20.  
  21.   onChangeDate(value) {
  22.     this.setState(() => ({
  23.       date: value
  24.     }));
  25.   }
  26.  
  27.   render() {
  28.     return (
  29.       <MuiPickersUtilsProvider utils={MomentUtils}>
  30.         <KeyboardDatePicker
  31.           disableToolbar
  32.           variant="inline"
  33.           format="YYYY/MM/DD"
  34.           margin="normal"
  35.           id="date-picker-wrapper"
  36.           label={this.label}
  37.           value={this.state.date}
  38.           onChange={(value) => this.onChangeDate(value)}
  39.           KeyboardButtonProps={{
  40.             'aria-label': 'change date',
  41.           }}
  42.         />
  43.       </MuiPickersUtilsProvider>
  44.     );
  45.   }
  46. }
  47.  
  48. DatePickerWrapper.propTypes = {
  49.   classes: PropTypes.object.isRequired
  50. };
  51.  
  52. const forExport = withStyles(styles)(DatePickerWrapper);
  53. export {forExport as DatePickerWrapper};
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top