Skip to content

Commit

Permalink
Add forwardRef to Datefield
Browse files Browse the repository at this point in the history
  • Loading branch information
Domino987 authored Jan 22, 2021
1 parent a41c19a commit fddb850
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/components/MTableEditField/DateField.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import React from 'react';
import DateFnsUtils from '@date-io/date-fns';
import { MuiPickersUtilsProvider, DatePicker } from '@material-ui/pickers';

export default function DateField({
function DateField({
columnDef,
value,
onChange,
locale,
forwardedRef,
...rest
}) {
const getProps = () => {
Expand All @@ -33,6 +34,7 @@ export default function DateField({
<MuiPickersUtilsProvider utils={DateFnsUtils} locale={locale}>
<DatePicker
{...datePickerProps}
ref={forwardedRef}
format={dateFormat}
value={value || null}
onChange={onChange}
Expand All @@ -49,3 +51,7 @@ export default function DateField({
</MuiPickersUtilsProvider>
);
}

export default React.forwardRef(function DateFieldRef(props, ref) {
return <DateField {...props} forwardedRef={ref} />;
});

0 comments on commit fddb850

Please sign in to comment.