react-admin icon indicating copy to clipboard operation
react-admin copied to clipboard

Warning: React does not recognize the `limitChoicesToValue` prop on a DOM element.

Open lehotskysamuel opened this issue 7 years ago • 3 comments

What you were expecting:

No warnings in the console.

What happened instead:

I see 2 warnings in the console when using ReferenceArrayInput with SelectInput. The first one is:

Warning: React does not recognize the `limitChoicesToValue` prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase `limitchoicestovalue` instead. If you accidentally passed it from a parent component, remove it from the DOM element.

The second one is:

index.js:1375 Warning: Received `true` for a non-boolean attribute `loaded`.

If you want to write it to the DOM, pass a string instead: loaded="true" or loaded={value.toString()}.

Steps to reproduce:

I am only using simple Create form with react-admin 3.0.1.

        <Create {...props}>
            <SimpleForm initialValues={{applicationId: application.id}}>
                <TextInput source="name"/>
                <TextInput source="description" multiline/>
                <ReferenceArrayInput
                    label="Do you want to use starter?"
                    source="templateId"
                    reference="appcomponent-template"
                >
                    {/*<Custom optionText={(record) => `${record.language} - ${record.displayName}`}/>*/}
                    <SelectInput optionText={(record) => `${record.language} - ${record.displayName}`}/>
                </ReferenceArrayInput>
            </SimpleForm>
        </Create>

Related code:

In the code above you can see commented-out Custom component. When I switch the SelectInput with the Custom component, the warnings are fixed because I don't propagate the 2 problematic props down the tree.

Custom component's definition: const Custom = ({limitChoicesToValue, loaded, ...rest}) => <SelectInput {...rest} />

Other information:

Environment

  • React-admin version: 3.0.1
  • Last version that did not exhibit the issue (if applicable):
  • React version: 16.12.0
  • Browser: Chrome 78.0.3904.108 64bit
  • Stack trace (in case of a JS error):
Warning: React does not recognize the `limitChoicesToValue` prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase `limitchoicestovalue` instead. If you accidentally passed it from a parent component, remove it from the DOM element.
    in div (created by ForwardRef(FormControl))
    in ForwardRef(FormControl) (created by WithStyles(ForwardRef(FormControl)))
    in WithStyles(ForwardRef(FormControl)) (created by ForwardRef(TextField))
    in ForwardRef(TextField) (created by WithStyles(ForwardRef(TextField)))
    in WithStyles(ForwardRef(TextField)) (created by ResettableTextField)
    in ResettableTextField (created by SelectInput)
    in SelectInput (at ComponentCreate.js:23)
    in ReferenceArrayInputView (created by ReferenceArrayInput)
    in ReferenceArrayInput (at ComponentCreate.js:17)
    in div (created by FormInput)
    in FormInput (created by SimpleFormView)
    in div (created by ForwardRef(CardContent))
    in ForwardRef(CardContent) (created by WithStyles(ForwardRef(CardContent)))
    in WithStyles(ForwardRef(CardContent)) (created by CardContentInner)
    in CardContentInner (created by SimpleFormView)
    in form (created by SimpleFormView)
    in SimpleFormView (created by ReactFinalForm)
    in ReactFinalForm (created by SimpleForm)
    in SimpleForm (at ComponentCreate.js:14)
    in div (created by ForwardRef(Paper))
    in ForwardRef(Paper) (created by WithStyles(ForwardRef(Paper)))
    in WithStyles(ForwardRef(Paper)) (created by ForwardRef(Card))
    in ForwardRef(Card) (created by WithStyles(ForwardRef(Card)))
    in WithStyles(ForwardRef(Card)) (created by CreateView)
    in div (created by CreateView)
    in div (created by CreateView)
    in CreateView (created by Create)
    in Create (at ComponentCreate.js:13)
    in Unknown (created by WithPermissions)
    in WithPermissions (created by Context.Consumer)
    in Route (created by ResourceRoutes)
    in Switch (created by ResourceRoutes)
    in ResourceRoutes (created by Resource)
    in Resource (at App.js:24)
    in Route (created by RoutesWithLayout)
    in Switch (created by RoutesWithLayout)
    in RoutesWithLayout (created by Context.Consumer)
    in div (created by Layout)
    in main (created by Layout)
    in div (created by Layout)
    in div (created by Layout)
    in Layout (created by WithStyles(Layout))
    in WithStyles(Layout) (created by Context.Consumer)
    in withRouter(WithStyles(Layout)) (created by ConnectFunction)
    in ConnectFunction (created by LayoutWithTheme)
    in ThemeProvider (created by LayoutWithTheme)
    in LayoutWithTheme (at Layout.js:6)
    in Unknown (created by Context.Consumer)
    in Route (created by CoreAdminRouter)
    in Switch (created by CoreAdminRouter)
    in div (created by CoreAdminRouter)
    in CoreAdminRouter (created by Context.Consumer)
    in Route (created by AdminUI)
    in Switch (created by AdminUI)
    in AdminUI (created by Admin)
    in Router (created by ConnectedRouter)
    in ConnectedRouter (created by Context.Consumer)
    in ConnectedRouterWithContext (created by ConnectFunction)
    in ConnectFunction (created by AdminContext)
    in TranslationProvider (created by AdminContext)
    in Provider (created by AdminContext)
    in AdminContext (created by Admin)
    in Admin (at App.js:17)
    in App (at src/index.js:6)

and

index.js:1375 Warning: Received `true` for a non-boolean attribute `loaded`.

If you want to write it to the DOM, pass a string instead: loaded="true" or loaded={value.toString()}.
    in div (created by ForwardRef(FormControl))
    in ForwardRef(FormControl) (created by WithStyles(ForwardRef(FormControl)))
    in WithStyles(ForwardRef(FormControl)) (created by ForwardRef(TextField))
    in ForwardRef(TextField) (created by WithStyles(ForwardRef(TextField)))
    in WithStyles(ForwardRef(TextField)) (created by ResettableTextField)
    in ResettableTextField (created by SelectInput)
    in SelectInput (at ComponentCreate.js:23)
    in ReferenceArrayInputView (created by ReferenceArrayInput)
    in ReferenceArrayInput (at ComponentCreate.js:17)
    in div (created by FormInput)
    in FormInput (created by SimpleFormView)
    in div (created by ForwardRef(CardContent))
    in ForwardRef(CardContent) (created by WithStyles(ForwardRef(CardContent)))
    in WithStyles(ForwardRef(CardContent)) (created by CardContentInner)
    in CardContentInner (created by SimpleFormView)
    in form (created by SimpleFormView)
    in SimpleFormView (created by ReactFinalForm)
    in ReactFinalForm (created by SimpleForm)
    in SimpleForm (at ComponentCreate.js:14)
    in div (created by ForwardRef(Paper))
    in ForwardRef(Paper) (created by WithStyles(ForwardRef(Paper)))
    in WithStyles(ForwardRef(Paper)) (created by ForwardRef(Card))
    in ForwardRef(Card) (created by WithStyles(ForwardRef(Card)))
    in WithStyles(ForwardRef(Card)) (created by CreateView)
    in div (created by CreateView)
    in div (created by CreateView)
    in CreateView (created by Create)
    in Create (at ComponentCreate.js:13)
    in Unknown (created by WithPermissions)
    in WithPermissions (created by Context.Consumer)
    in Route (created by ResourceRoutes)
    in Switch (created by ResourceRoutes)
    in ResourceRoutes (created by Resource)
    in Resource (at App.js:24)
    in Route (created by RoutesWithLayout)
    in Switch (created by RoutesWithLayout)
    in RoutesWithLayout (created by Context.Consumer)
    in div (created by Layout)
    in main (created by Layout)
    in div (created by Layout)
    in div (created by Layout)
    in Layout (created by WithStyles(Layout))
    in WithStyles(Layout) (created by Context.Consumer)
    in withRouter(WithStyles(Layout)) (created by ConnectFunction)
    in ConnectFunction (created by LayoutWithTheme)
    in ThemeProvider (created by LayoutWithTheme)
    in LayoutWithTheme (at Layout.js:6)
    in Unknown (created by Context.Consumer)
    in Route (created by CoreAdminRouter)
    in Switch (created by CoreAdminRouter)
    in div (created by CoreAdminRouter)
    in CoreAdminRouter (created by Context.Consumer)
    in Route (created by AdminUI)
    in Switch (created by AdminUI)
    in AdminUI (created by Admin)
    in Router (created by ConnectedRouter)
    in ConnectedRouter (created by Context.Consumer)
    in ConnectedRouterWithContext (created by ConnectFunction)
    in ConnectFunction (created by AdminContext)
    in TranslationProvider (created by AdminContext)
    in Provider (created by AdminContext)
    in AdminContext (created by Admin)
    in Admin (at App.js:17)
    in App (at src/index.js:6)

lehotskysamuel avatar Nov 29 '19 14:11 lehotskysamuel

You can't use ReferenceArrayInput with SelectInput - only with SelectArrayIpnut.

fzaninotto avatar Nov 29 '19 16:11 fzaninotto

Hmm, thanks. Maybe this could be a feature request then? The interface for both components looks the same to me (choices, optionText, optionValue...). I thought the only difference is a single-choice select vs multiple-choices select.

Also, I see now that documentation mentions The SelectArrayInput component cannot be used inside a ReferenceInput but can be used inside a ReferenceArrayInput. but doesn't mention the same for ReferenceInput and SelectInput.

lehotskysamuel avatar Dec 03 '19 09:12 lehotskysamuel

We won't implement such feature, it would be too confusing.

fzaninotto avatar Dec 03 '19 09:12 fzaninotto