So I have the following situation (all are functional components).
<Main>
, where it returns
<Comp A>
<Comp B>
...
{children}
...
I have a piece of info that I want to use in both <Comp A>
and sometimes, {children} - I can do it in <Comp A>
and the specific {children} separately, but that seems a bit redundant to me. I'm trying to hit that API once in <Main>
, and pass the info to both <Comp A>
and {children}.React pass props to children and have followed along several solutions, but I'm having trouble accessing the data passed to children.
The structure of my use case might be important here: I'm trying to access the data in <Other Comp>
, which is defined as
<Main>
<div>blablabla</div>
</Main>
And my goal is to say, be able to render whatever is passed in the "blablabla" part of the code. So the <Other Comp>
isn't technically a child of Main, but it is filling in the {children} part. Wonder if this is possible at all? Thanks!