-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade to latest versions of React Admin and Material-UI #20
Comments
Done in 1.1.1 |
It seems like the issue on react-admin's repo was due to a wrong version of material-ui. |
I'm having issues with this at the moment, what is the best work around for this? |
Use the correct material-ui version (I believe 1.4.0 right now but you can
check react-admin/packages/ra-ui-materialui/package.json for an up to date
answer)
…On Mon, Jan 21, 2019, 23:00 Amir Ghorbani ***@***.*** wrote:
I'm having issues with this at the moment, what is the best work around
for this?
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#20 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAmuSSkTNFLDr-nxyKIV26gmrDkWpoJUks5vFjiEgaJpZM4aK8Mp>
.
|
amazing, thanks for the quick response @vascofg |
Ref to my anwser about React Admin supporting Material UI v3: #22 (comment) |
I wrote this using forwardRef function and using the latest material-ui version. Added also the KeyboardTimePicker option in exports. import MomentUtils from "@date-io/moment";
import {
DatePicker,
DateTimePicker,
MuiPickersUtilsProvider,
TimePicker,
KeyboardDatePicker
} from "@material-ui/pickers";
import PropTypes from "prop-types";
import { addField, FieldTitle, useTranslate } from "ra-core";
import React from "react";
const makePicker = PickerComponent => {
const _makePicker = React.forwardRef((props, ref) => {
const translate = useTranslate();
const onChange = date => {
props.input.onChange(date);
props.input.onBlur();
};
const {
input,
options,
label,
source,
resource,
isRequired,
className,
meta,
providerOptions
} = props;
const { touched, error } = meta;
return (
<div className="picker">
<MuiPickersUtilsProvider {...providerOptions}>
<PickerComponent
{...options}
label={
<FieldTitle
label={label}
source={source}
resource={resource}
isRequired={isRequired}
/>
}
error={!!(touched && error)}
helperText={touched && translate(error)}
ref={ref}
className={className}
value={input.value ? input.value : null}
onChange={date => onChange(date)}
/>
</MuiPickersUtilsProvider>
</div>
);
});
_makePicker.propTypes = {
input: PropTypes.object,
isRequired: PropTypes.bool,
label: PropTypes.string,
meta: PropTypes.object,
options: PropTypes.object,
resource: PropTypes.string,
source: PropTypes.string,
labelTime: PropTypes.string,
className: PropTypes.string,
providerOptions: PropTypes.shape({
utils: PropTypes.func,
locale: PropTypes.oneOfType([PropTypes.object, PropTypes.string])
})
};
_makePicker.defaultProps = {
input: {},
isRequired: "false",
label: "",
meta: { touched: false, error: false },
options: {},
resource: "",
source: "",
labelTime: "",
className: "",
providerOptions: {
utils: MomentUtils,
locale: undefined
}
};
return _makePicker;
};
export const DateInput = addField(makePicker(DatePicker));
export const KeyboardDateInput = addField(makePicker(KeyboardDatePicker));
export const TimeInput = addField(makePicker(TimePicker));
export const DateTimeInput = addField(makePicker(DateTimePicker)); |
Hi, React Admin maintainers here. Thanks for making this lib!
We had an issue about your library on react-admin: marmelab/react-admin#2795
react-admin-date-inputs
seems to no longer be working because of out-to-date dependencies.I closed the issue because it is not directly related to react-admin.
I see that you have a opened PR about this: #17
Let me know if you need something more to support the latest versions of RA!
The text was updated successfully, but these errors were encountered: