mukesh joshi
mukesh joshi

Reputation: 594

react ComponentDidMount

From my parent react component's render method I am creating a list of child radio button components.

I need to call a method once the render is completed, i.e., children components are also rendered completely.

I tried following mechanism:

  1. passed a callback: It didn't worked. It was called before rendering.
  2. called the method directly in componentDidMount. Same issue
  3. called the method in componentDidUpdate. Same issue

I am passing all the data through props to parent -> child and there is no redux involved.

How I can achieve this ?

Upvotes: 2

Views: 3214

Answers (1)

Bamieh
Bamieh

Reputation: 10906

simply wrap in a timeout in the parent component's componentDidMount

componentDidMount() {
   setTimeout(this.myMethod, 1000/60)
}

componentDidUpdate is not invoked on the initial render, hence you cannot use it.

Upvotes: 1

Related Questions