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

shallowCompare not set on React.addons (npm version 0.13.3) #4315

Closed
pocketjoso opened this issue Jul 8, 2015 · 9 comments
Closed

shallowCompare not set on React.addons (npm version 0.13.3) #4315

pocketjoso opened this issue Jul 8, 2015 · 9 comments

Comments

@pocketjoso
Copy link

According to the docs for react-codemod, React > 0.13.x should include React.addons.shallowCompare (which is used by the PureRenderMixin transformation) - but when installing react from npm this is not the case. In the locally installed react node module lib/ReactWithAddons is missing this line. Is the npm package not up to date, or what else is wrong here?

If it matters:
react: 0.13.3
npm: 2.12.1
OSX

(I know this error will go away with 0.14.x, but we can't really upgrade to that while it's in beta..

@zpao
Copy link
Member

zpao commented Jul 8, 2015

Hmm, #3355 landed after we shipped v0.13.0 and we never took that in the stable branch. At this point (going on 4 months later) we're not going to add it now so we should update the docs for react-codemod, then figure out the right thing for 0.14. cc @cpojer

@pocketjoso
Copy link
Author

Thanks for quick response. Any suggestions for how to best make use of react-codemod for upgrading to 0.13.x then? I'm guessing perhaps hacking that specific (PureRenderMixin) test..

@cpojer
Copy link
Contributor

cpojer commented Jul 8, 2015

This is unfortunate. We are thinking of adding a flag to React components that denotes whether they are pure (cc @sema). Once we have this I will update the codemod accordingly.

@pocketjoso I would suggest, in your main component (or any side-effectful component that sets up your environment), to manually add React.addons.shallowCompare. You'll be able to remove this once we ship a React version that exports this function or once we add the flag I mentioned before.

@pocketjoso
Copy link
Author

@cpojer It is unfortunate indeed, because it makes codemod a lot less useful out of the box. I will monkeypatch React.addons to add the shallowCompare function.

@jardakotesovec
Copy link

According to release notes shallowCompare is now separate package react-addons-shallow-compare.

@cpojer Can we expect codemod update that use this package instead of React.addons ?

Thanks!

@cpojer
Copy link
Contributor

cpojer commented Oct 15, 2015

Oh, I missed this! Yeah absolutely, this shouldn't be that big of a deal, except of course adding a require/import at the right location is still hard :)

@cpojer
Copy link
Contributor

cpojer commented Oct 15, 2015

I'm quite swamped with work on jest at the moment. Is this something you'd be interested in sending a PR for, @jardakotesovec ?

@jardakotesovec
Copy link

@cpojer Unfortunately also swamped with more pressing stuff.

@zpao
Copy link
Member

zpao commented Oct 20, 2015

Moved to reactjs/react-codemod#2

@zpao zpao closed this as completed Oct 20, 2015
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

4 participants