Skip to content

Commit

Permalink
Merge pull request #9690 from marmelab/fix-referenceinput-throw
Browse files Browse the repository at this point in the history
Fix `<ReferenceInput>` throws a recoverable error in production
  • Loading branch information
slax57 authored Mar 1, 2024
2 parents 0e4c7ca + 39becc7 commit da8f974
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions packages/ra-ui-materialui/src/input/ReferenceInput.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Children, ReactElement } from 'react';
import React, { ReactElement } from 'react';
import PropTypes from 'prop-types';
import {
ChoicesContextProvider,
Expand Down Expand Up @@ -84,14 +84,11 @@ export const ReferenceInput = (props: ReferenceInputProps) => {
filter,
});

if (props.validate) {
if (props.validate && process.env.NODE_ENV !== 'production') {
throw new Error(
'<ReferenceInput> does not accept a validate prop. Set the validate prop on the child instead.'
);
}
if (Children.count(children) !== 1) {
throw new Error('<ReferenceInput> only accepts a single child');
}

return (
<ResourceContextProvider value={reference}>
Expand Down

0 comments on commit da8f974

Please sign in to comment.