diff --git a/packages/ra-ui-materialui/src/input/ReferenceInput.js b/packages/ra-ui-materialui/src/input/ReferenceInput.js
index b46bd68bb9..a012a643e1 100644
--- a/packages/ra-ui-materialui/src/input/ReferenceInput.js
+++ b/packages/ra-ui-materialui/src/input/ReferenceInput.js
@@ -1,6 +1,6 @@
import React, { Children, cloneElement } from 'react';
import PropTypes from 'prop-types';
-import { addField, useReferenceInputController } from 'ra-core';
+import { useInput, useReferenceInputController } from 'ra-core';
import LinearProgress from '../layout/LinearProgress';
import Labeled from './Labeled';
@@ -85,9 +85,28 @@ import ReferenceError from './ReferenceError';
*
*
*/
-export const ReferenceInput = props => (
-
-);
+export const ReferenceInput = ({
+ onBlur,
+ onChange,
+ onFocus,
+ validate,
+ ...props
+}) => {
+ const inputProps = useInput({
+ onBlur,
+ onChange,
+ onFocus,
+ validate,
+ ...props,
+ });
+ return (
+
+ );
+};
ReferenceInput.propTypes = {
allowEmpty: PropTypes.bool.isRequired,
@@ -97,14 +116,12 @@ ReferenceInput.propTypes = {
classes: PropTypes.object,
filter: PropTypes.object,
filterToQuery: PropTypes.func.isRequired,
- input: PropTypes.object.isRequired,
label: PropTypes.string,
- meta: PropTypes.object,
onChange: PropTypes.func,
perPage: PropTypes.number,
record: PropTypes.object,
reference: PropTypes.string.isRequired,
- resource: PropTypes.string.isRequired,
+ resource: PropTypes.string,
sort: PropTypes.shape({
field: PropTypes.string,
order: PropTypes.oneOf(['ASC', 'DESC']),
@@ -120,8 +137,6 @@ ReferenceInput.defaultProps = {
sort: { field: 'id', order: 'DESC' },
};
-const EnhancedReferenceInput = addField(ReferenceInput);
-
const sanitizeRestProps = ({
allowEmpty,
basePath,
@@ -248,4 +263,4 @@ ReferenceInputView.propTypes = {
warning: PropTypes.string,
};
-export default EnhancedReferenceInput;
+export default ReferenceInput;