"stateful" react injection #43
Description
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.