react-archer: My ArcherElements are defined in another component, so I am getting "Could not find "unregisterChild" in the context of "
I have a component that looks a little something like:
<MyApp>
<ArcherContainer>
<ThirdPartyComponent itemRenderer={() => (<ContainsArcherElement />)}
</ArcherContainer>
</MyApp>
And then ContainsArcherElement is similar to:
const ContainsArcherElement = () => (
<SomethingElse>
<ArcherElement /> // with all the right props
</SomethingElse>
)
But I’m getting the full Could not find "unregisterChild" in the context of <ArcherElement>. Wrap the component in a <ArcherContainer>. but it should be wrapped, just not immediately.
Is there a way around this, and is it a bug or a feature?
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 20 (15 by maintainers)
@AncientSwordRage Context is not passed through into your
rendercomponent, and React has no smart way to make that possible. The container could expose the context and you could manually pass it, but I don’t think that just works off the top of my head.@AncientSwordRage Sorry, but I can only be so nice sometimes. When someone tells you that you’re confused and an idiot, and then goes on to reference a pull request that you contributed to as evidence, I’m going to tell them off. Engineers and their egos know no bounds.
The feature has to be added, but I can look into it later today.
@gurkerl83 Don’t talk down to me. If you actually knew what you were talking about, then you would know that React Redux is not built with context. I know that because Mark asked me to add my input on the v6.0 release, where they moved from subscriptions to context. That was a disaster, as it added back the old zombie children issues with legacy context, and they eventually removed it.
No, they weren’t.
You seem to be the only one that is confused.
@AncientSwordRage The importing/exporting is correct. This is going to sound obnoxious but I did talk to Dan Abramov about this API design before hooks came out, and I was exporting the context consumer like this in all the examples I gave.
@pierpo The
withContainerContextAPI looks good. You can just export that itself as part of the public API, so you don’t have to pass refs. This is all valid JS.Where is it exported/reimported? It is indeed exported but only for the tests of the library.
@jfo84 is right, the only way I can think of is indeed exposing the context, but I have no idea how it would work out.
This:
should become… this?
so that you can do
I think this would work 🤔 I haven’t tried it out, maybe I’m wrong.
But I’m not sure what the impact of the change above would have on ArcherContainer in general 🧐