chenglou / react-chosen

React wrapper for Chosen jQuery.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using with React 0.11.0?

pjm17971 opened this issue · comments

Have you tried react-chosen with React v0.11.0? We moved to that version last night and the chosen stuff now seems broken:

Error example 1:

Uncaught TypeError: Can't add property __keyValidated__, object is not extensible

The stack trace leads down to a <Chosen ... /> within a higher level component.

Error example 2:

Invalid access to component property "updateComponent" on Chosen in TagsEditView. See http://fb.me/react-warning-descriptors . Use a static method instead: <Chosen />.type.updateComponent(...)

We use it via npm/browserify.

I'm testing this locally and can't seem to repro it. component property "updateComponent" on Chosen is obviously wrong. Do you have an updateComponent on your side?

No. What wraps the Chosen component on my side is pretty simple. I'm really just including <Chosen ... /> in my render().

But I did just discover that if I change react-chosen's package.json to depend on react 0.11.0 and npm update react-chosen, my page starts to load again! I guess ^0.10.0 won't pull in 0.11.0 automatically. I'm surprised that matters, but I guess I am then including a react v0.10.0 child within my v0.11.0 parent, so maybe something breaks doing that?

The new ^ default can trip people up. If you want to see the version of React used, check React.version in the console.

And yes, if you have two different versions of React on the same page, it'd error. This is a known problem and not an easy one to solve (not React's fault, but dependency management in general). We're thinking of throwing when we detect two Reacts. You really shouldn't bloat up your final js output twice or thrice because one or two components required a different React anyways.

So if you can check and make sure this lib works with 0.11.0 through React.version, it'd be great (I already tested but I'd like some double check). Then I can bump this to 0.11.

Thanks for looking into this. Yes, agreed on all your points. Although, I use browserify, so React.version won't work. React shouldn't be in the global namespace like that. In my case the uses (mine, and react-chosen) should be isolated to themselves (via var React = require("react")), but still they need to play nice with each other and apparently don't.

When I moved the dependency of react-chosen to 0.11.0 it works fine. I have multi- and single select styles etc, so I feel pretty confident in it.

(You can console.log that from any file that requires React btw.)

Alright thanks, will update soon.

Done.