Skip to content
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

Fix <ReferenceInput> throws a recoverable error in production #9690

Merged
merged 2 commits into from
Mar 1, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 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';

Check warning on line 1 in packages/ra-ui-materialui/src/input/ReferenceInput.tsx

View workflow job for this annotation

GitHub Actions / typecheck

'Children' is defined but never used. Allowed unused vars must match /^_/u
import PropTypes from 'prop-types';
import {
ChoicesContextProvider,
Expand Down Expand Up @@ -84,14 +84,11 @@
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');
}
slax57 marked this conversation as resolved.
Show resolved Hide resolved

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