Skip to content

Commit

Permalink
Fix <ReferenceInput> throws a recoverable error in production
Browse files Browse the repository at this point in the history
## Problem

Since #9637, users see an error in production while the app isn't broken

## Solution

Only throw in development.
  • Loading branch information
fzaninotto committed Feb 29, 2024
1 parent 601a0d6 commit 1d9ebdc
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions packages/ra-ui-materialui/src/input/ReferenceInput.tsx
Original file line number Diff line number Diff line change
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 1d9ebdc

Please sign in to comment.