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

Invariant Violation since 0.6.1 #294

Closed
tuhlmann opened this issue Apr 21, 2017 · 5 comments
Closed

Invariant Violation since 0.6.1 #294

tuhlmann opened this issue Apr 21, 2017 · 5 comments

Comments

@tuhlmann
Copy link

Since I switched my project from reagent 0.6.0 to 0.6.1 I regularly get the following warning message when switching views:

Warning: Exception thrown by hook while handling onSetChildren: Invariant Violation: Item must have been set
Invariant Violation: Item must have been set
    at invariant (http://localhost:10555/js/out/cljsjs/react-with-addons/development/react-with-addons.inc.js:5160:15)
    at Object.onSetChildren (http://localhost:10555/js/out/cljsjs/react-with-addons/development/react-with-addons.inc.js:1905:46)
    at callHook (http://localhost:10555/js/out/cljsjs/react-dom/development/react-dom.inc.js:8364:8)
    at emitEvent (http://localhost:10555/js/out/cljsjs/react-dom/development/react-dom.inc.js:8376:7)
    at Object.onSetChildren (http://localhost:10555/js/out/cljsjs/react-dom/development/react-dom.inc.js:8648:5)
    at ReactCompositeComponentWrapper._updateRenderedComponent (http://localhost:10555/js/out/cljsjs/react-dom/development/react-dom.inc.js:5209:42)
    at ReactCompositeComponentWrapper._performComponentUpdate (http://localhost:10555/js/out/cljsjs/react-dom/development/react-dom.inc.js:5163:10)
    at ReactCompositeComponentWrapper.updateComponent (http://localhost:10555/js/out/cljsjs/react-dom/development/react-dom.inc.js:5084:12)
    at ReactCompositeComponentWrapper.performUpdateIfNecessary (http://localhost:10555/js/out/cljsjs/react-dom/development/react-dom.inc.js:5000:12)
    at Object.performUpdateIfNecessary (http://localhost:10555/js/out/cljsjs/react-dom/development/react-dom.inc.js:11616:22)

There's this bug in React: facebook/react#8487 , is that related?

I tried to run it with dependency vectors

                 [reagent "0.6.1" :exclusions [cljsjs/react]]
                 [cljsjs/react-with-addons "15.4.2-2"]

or

                 [reagent "0.6.1" :exclusions [cljsjs/react]]
                 [cljsjs/react-with-addons "15.5.0-0"]

and also with the included react package- all produce the same warning.

Is there anything I can do to trace the root of the problem? Should I just wait for the next React release?

Thanks!

@tuhlmann
Copy link
Author

I think the problem is with a call to render-to-static-markup in one of my components.
I use it to render the toolbar of a QuillJS editor component from Hiccup to html. This call is executed each time the editor component is shown.

When removing this call the warning is gone.
Am I doing something wrong, Can I use render-to-static-markup for this purpose and should I use it differently?

@Deraen
Copy link
Member

Deraen commented Apr 21, 2017

When updating the dependency (15.5) did you update all the react packages:

[cljsjs/react-with-addons "15.5.0-0"]
[cljsjs/react-dom "15.5.0-0"]
[cljsjs/react-dom-server "15.5.0-0"]

The versions for each package have to match. You can validate this with lein deps / boot show --deps.

@tuhlmann
Copy link
Author

Thanks @Deraen , that seemed to have fixed it.
I really only included the react-with-addons dep, not the other two. I thought they are implicitely included by react-with-addons package.

Now I get these two warnings:

Warning: Accessing PropTypes via the main React package is deprecated. Use the prop-types package from npm instead.

react-with-addons.inc.js:4946 Warning: AutosizeInput: React.createClass is deprecated and will be removed in version 16. Use plain JavaScript classes instead. If you're not yet ready to migrate, create-react-class is available on npm as a drop-in replacement.

Is it correct to assume that these occur because reagent doesn't target this new react version yet and they will be resolved with a later version of reagent?

Please allow one more question:

Is this dependency statement correct or do I need to exclude more packages if I want to add my own react:

[reagent "0.6.1" :exclusions [cljsjs/react]]

Thanks!

@Deraen
Copy link
Member

Deraen commented Apr 21, 2017

Is it correct to assume that these occur because reagent doesn't target this new react version yet and they will be resolved with a later version of reagent?

Yes, this is correct. There is a issue about this: #292

Is this dependency statement correct or do I need to exclude more packages if I want to add my own react:
[reagent "0.6.1" :exclusions [cljsjs/react]]

This is okay if you just change the cljsjs/react to cljsjs/react-with-addons. If you use the same version as Reagent already uses, you just need to add react-with-addons dep. If you use different version, you need to add all three deps.

If you use something else than cljsjs packages to provide React (e.g. npm-deps), you need to exclude all three deps and create empty stub namespaces which provide cljsjs.react, cljsjs.react.dom and cljsjs.react.dom.server and take care that your own React is loaded before Reagent tries to access window.React.

@tuhlmann
Copy link
Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants