Skip to content

Closure Compiler: wrong assignment order in instantiateReactComponent #8894

@anmonteiro

Description

@anmonteiro

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions