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

Overriding Form validation messages throws a console exception #3910

Closed
myktra opened this issue Apr 2, 2020 · 1 comment
Closed

Overriding Form validation messages throws a console exception #3910

myktra opened this issue Apr 2, 2020 · 1 comment
Labels
bug issue that does not match design or documentation and requires code changes to address waiting Awaiting response to latest comments

Comments

@myktra
Copy link

myktra commented Apr 2, 2020

Expected Behavior

Overriding the messages prop on a controlled Form component to provide a different validation message runs normally without observable exceptions.

Actual Behavior

When keying characters into an empty TextInput-based field in this scenario, React throws an exception to the console after the second character is entered. This occurs whether or not the TextInput field is wrapped by a FormField component or whether the field is even marked required.

Warning: Cannot update a component (`App`) while rendering a different component (`Form`). To locate the bad setState() call inside `Form`, follow the stack trace as described in https://fb.me/setstate-in-render
    in Form (at App.js:13)
    in div (created by StyledBox)
    in StyledBox (created by Box)
    in Box (at App.js:12)
    in div (created by StyledGrommet)
    in StyledGrommet (created by Grommet)
    in Grommet (at App.js:11)
    in App (at src/index.js:9)
    in StrictMode (at src/index.js:8)

This behavior is observable on Grommet 2.12.0 w/React 16.13.1. The behavior does NOT occur when paired with React 16.12.

Note that if the messages prop is removed from the Form component the unwanted behavior no longer presents. And whether or not the exception is thrown the validation functionality actually appears to work (in this example overriding the message for a required field).

URL, screen shot, or Codepen exhibiting the issue

https://codesandbox.io/s/nervous-dubinsky-k7iul

Steps to Reproduce

Try the example. Start typing into the input field and watch the console.

AFAICT this is a behavior introduced in React 16.13. Lots of related issues in the React repo, with solutions almost always required in the component libraries using it, which would seem to suggest a solution is required inside Grommet.

See:

facebook/react#18178
WordPress/gutenberg#21049
reactive/data-client#300

Your Environment

  • Grommet version: 2.12.0
  • React version: 16.13.x
  • Browser Name and version: Chrome 80
  • Operating System and version (desktop or mobile): macOS 10.15
@ShimiSun ShimiSun added the bug issue that does not match design or documentation and requires code changes to address label May 27, 2020
@IanKBovard
Copy link
Contributor

I no longer see this error in the current version of grommet(2.15). I believe this issue can be closed.

@ShimiSun ShimiSun added the waiting Awaiting response to latest comments label Aug 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug issue that does not match design or documentation and requires code changes to address waiting Awaiting response to latest comments
Projects
None yet
Development

No branches or pull requests

3 participants