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

[FormControl] Maximum update depth exceeded #12197

Closed
Mangatt opened this issue Jul 19, 2018 · 6 comments
Closed

[FormControl] Maximum update depth exceeded #12197

Mangatt opened this issue Jul 19, 2018 · 6 comments
Labels
docs Improvements or additions to the documentation good first issue Great for first contributions. Enable to learn the contribution process.

Comments

@Mangatt
Copy link
Contributor

Mangatt commented Jul 19, 2018

Apparently, [FormControl] component supports only one [Input]. Following code throws error Maximum update depth exceeded

<FormControl>
    <Input value="a" />
    <Input value="" />
</FormControl>

When both [Input]s are with empty value or both are filled, everything is okay. When one is filled and other is not, error is thrown.

I'm not sure if this is bug, but if that is intentional, I guess that Docs should mention that and React.Children.only should be used.

@oliviertassinari
Copy link
Member

oliviertassinari commented Jul 19, 2018

I guess that Docs should mention that and React.Children.only should be used.

@Mangatt You can only use a single input within a FormControl. But it doesn't mean you can't use a label + input + helper text.

@Mangatt
Copy link
Contributor Author

Mangatt commented Jul 19, 2018

Noted, thanks.

I would probably mention that in [FormControl] docs, it's better than finding out yourself.

@oliviertassinari oliviertassinari added docs Improvements or additions to the documentation good first issue Great for first contributions. Enable to learn the contribution process. labels Jul 19, 2018
@oliviertassinari
Copy link
Member

@Mangatt I agree, I think that we could add a note about it in the FormControl API documentation page:
https://github.com/mui-org/material-ui/blob/d0efa75ce0b2e9b194fddfb833d6f852190cd3cb/packages/material-ui/src/FormControl/FormControl.js#L37-L46

Is this something you want to work on? :)

@Mangatt
Copy link
Contributor Author

Mangatt commented Jul 23, 2018

Sure, I can try. Let me dive into contributing guidelines first.

@voliva
Copy link

voliva commented Oct 21, 2020

This no longer happens in master. See this sandbox: https://codesandbox.io/s/material-ui-issue-forked-my1u6?file=/src/Demo.js

I've bisected it was (probably unexpectedly) fixed in #17436 (version 4.4.3 onward), but the warning message from #16907 is still shown.

Is it something that should be avoided even if it works? I have a use case where I need to have a composed control of a Select + Input (e.g. Phone type + phone number makes a single control "Phone" that should have a unified validation)

@oliviertassinari @eps1lon

@oliviertassinari
Copy link
Member

oliviertassinari commented Oct 21, 2020

@voliva We recommend to avoid it because some states are meant to impact a single textbox, e.g. focused, filled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to the documentation good first issue Great for first contributions. Enable to learn the contribution process.
Projects
None yet
Development

No branches or pull requests

3 participants