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

Closure Compiler: wrong assignment order in instantiateReactComponent #8894

Closed
anmonteiro opened this issue Jan 30, 2017 · 2 comments · Fixed by #8895
Closed

Closure Compiler: wrong assignment order in instantiateReactComponent #8894

anmonteiro opened this issue Jan 30, 2017 · 2 comments · Fixed by #8895

Comments

@anmonteiro
Copy link
Contributor

When consuming React from source with the Google Closure Compiler, this bit of code isn't being run in the correct order.

It seems like the Google Closure Compiler transformation is changing the function to a var assignment. It messes up the behavior because the original instantiateReactComponent function is hoisted. My thought is it's related to the fact that the instantiateReactComponent function is exported from that module.

Anyway, this produces an error because the assignment to ReactCompositeComponentWrapper.prototype is now in the wrong order (assignment -> function definition, when we want definition -> assignment).

This may also be related or the root cause of #8887.

The most straightforward solution is to bring the Object.assign call after the function is declared, which I've verified works correctly. I'm happy to submit a PR with the described approach.

@aweary
Copy link
Contributor

aweary commented Jan 30, 2017

Feel free to open a PR for review! @anmonteiro

@anmonteiro
Copy link
Contributor Author

Thanks. Submitted in #8895

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

Successfully merging a pull request may close this issue.

2 participants