Skip to content
This repository was archived by the owner on Sep 7, 2022. It is now read-only.
This repository was archived by the owner on Sep 7, 2022. It is now read-only.

"stateful" react injection #43

Closed
Closed
@timse

Description

@timse

I guess this is a very constructed case, but I am wondering about https://github.com/webcomponents/react-integration/blob/master/src/index.js#L30 .

What was the decision for:

opts = assign(defaults, opts);

intead of

opts = assign({}, defaults, opts);

Again one should imagine that if you inject React and ReactDOM once, it will be injected all the time, however in a very constructed use case we could have some code like this:

const SomeComponent = reactify(SomeWebComponent);

const SomeOtherComponent = reactify(SomeOtherWebComponent);

if I were to be mean I could now call reactifiy before all those calls like so:

try{
    reactify(null, {React: null, ReactDom: null})
} catch (e){}

killing all following calls to reactify as they will no longer have access to React or ReactDOM.

In fact if you remove the , { ReactDOM: null } part from this line: https://github.com/webcomponents/react-integration/blob/master/test/unit/errors.js#L11

the test will still be green, as React is still null. Setting ReactDOM to null does not cause the throw here.

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