0

Basically If I have react components like

<ParentComponent>
  <ChildComponent />
</ParentComponent>

function ParentComponent(){
  useEffect(() => {
    parentApi();
  },[])
  return <>Parent Component</>
}

function ChildComponent (){
  useEffect(() => {
    childApi();
  },[])
  return <>Child Component</>
}

Now these api will be called in following order because that's how useEffect work

childApi parentApi

But my few props of child component need data from parentApi.So how can I ensure order in which these api's are called is

parentApi childApi

Basically I want hook something like componentWillMount.

0 Answers0