Skip to content

Instantly share code, notes, and snippets.

@compwron
Created August 31, 2017 21:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save compwron/9068e473e9702f442b2a67de7e056515 to your computer and use it in GitHub Desktop.
Save compwron/9068e473e9702f442b2a67de7e056515 to your computer and use it in GitHub Desktop.
clearable-material-ui-date-picker.js
// credit to Michael Lennon
import React, {Component, button} from "react";
import PropTypes from "prop-types";
import DatePicker from "material-ui/DatePicker";
import moment from "moment-timezone";
function DatePickerClearable({style, datePickerStyle={}, ...datePickerProps}) {
function clearBtnClickWrapper() {
datePickerProps.onChange(null, null); // (event, newValue)
}
return (
<div>
<DatePicker
style={datePickerStyle}
{...datePickerProps}
fullWidth={true}
/>
<button
onTouchTap={clearBtnClickWrapper}
>Clear</button>
</div>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment