Calling a method of grand-grandchild from parent component in react

I have a functional component with consuming a context which has a function of the context that needs to be called from the grand-grandparent.

const Bar = () => {
  return (
    <ContextProvider>
      <BarContent/>
    </ContextProvider>
  )
}

The grand-grandparent is <Container/> which is a class component. Basically the component structure is as follows,

<Container> // <= class component
  <InnerContainer>
    <Bar/>
  </InnerContainer>
</Container>

I need to call a method on <BarContent/> which exposed to that from the context it uses. I have tried using React.forwardRef to call it, but no success at all.

How could I access the method inside the <BarContent/> from <Container/>



from Recent Questions - Stack Overflow https://ift.tt/3iMFtO0
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Spring Elasticsearch Operations

Network Error and Timeout on Authorize.net JS

Object oriented programming concepts (OOPs)