-
-
Notifications
You must be signed in to change notification settings - Fork 297
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
Uncaught Invariant Violation #56
Comments
@123ndy React version? |
React version 15.2.0 |
I was getting the same error, but in my case the error was triggered by a MediaQuery component with a maxWidth. I do not know what is causing this, but screen size seems to be a factor. (I was only seeing the error when using a small screen.) In my case, wrapping the contents of MediaQuery with a div tag made the error go away. This might be an acceptable workaround for most people. I was getting the error when the render function of the MediaQuery component was returning an empty array. The final "else" in the render function returns this.props.children, which was an empty array in this case. A possible bug fix could be to replace this:
with this:
(replace "> 1" with "!== 1"). I do not know if that fixes a bug, but it makes the error go away in my case. |
@rhavill I think a more permanent fix is to return null when 0 children exist instead of an empty array. Want to send a PR? |
…nder function when MediaQuery has no children.
Fix for Uncaught Invariant Violation #56.
Closed by #62 |
This works:
This creates error:
The only difference is that I use
maxWidth
in the first andminWidth
in the latter.Any idea why this happens?
Error:
Uncaught Invariant Violation: MediaQuery.render(): A valid React element (or null) must be returned. You may have returned undefined, an array or some other invalid object.
The text was updated successfully, but these errors were encountered: