YahooArchive / fluxible-router

MOVED TO FLUXIBLE REPO
104 stars 26 forks source link

React and Fluxible shoud be peerDependency #20

Closed peleteiro closed 9 years ago

peleteiro commented 9 years ago

Running two different reacts, even if they are the same versions, causes problems that are hard to debug and understand.

I just had a problem where context weren't passed trough handleRoute.

myproject/node_modules/fluxible-router/lib/handleRoute.js:24
var routeStore = this.context.getStore('RouteStore');
TypeError: undefined is not a function

If I remove node_modules/fluxible-router/node_modules/react/ it works.

I know peerDependency is not a perfect solution, but is the best one available for React components/libraries.

This problem only occurs on server-side, due to the nature of npm, on the client-side you always run only one React.

mridgway commented 9 years ago

Hmm, React is already a peerDependency though, so not sure why it would be installed under fluxible-router as well as the top level.

In other news, I can't wait for React 0.14 to solve this context nonsense.

peleteiro commented 9 years ago

But fluxible is not a peerDependency; React is a peerDependency of fluxible and it gets installed in fluxible-router's node_modules.

This behaviour will change, and peerDependency will not install automatically. But for now...

mridgway commented 9 years ago

If you require react in your application, it should get installed there and not in your dependencies. Is that not working? It has been working for us in our flux-examples just fine.

peleteiro commented 9 years ago

I was requiring react using "react": "~0.13", I changed to "react": "0.13.x" as flexible-router is using and it works.

I lost a couples of hours trying to solve this, I would still put fluxible as a peerDependency but I'm good for now. peerDependency is changing soon any way.

Thank you!

mridgway commented 9 years ago

@peleteiro Good to hear that you got it work. peerDependencies have always been a pain for us too. Out of curiosity, which version of npm are you using? This might help with diagnosing for people with similar issues in the future.

peleteiro commented 9 years ago

@mridgway 2.7.5, the last one available on brew.