Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

214
Views
How to check that a certain prop has received?

I have an synchronization issue. I want to check props is loaded or not to child component. I have wrote a code like that :

  componentDidMount() {
    setTimeout(() => {
      this.setState({
        editorContent: this.props.json[this.state.contentType],
      });
    }, 2500);
  }

Here I'm using 'setTimeout' function. In render function I'm using 'editorContent' state so this is undefined if I don't use 'setTimeout'. After 1 or 2 sec. props received and it won't be undefined. I guess there is better solution for that. Thanks all

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

This method is completely not sustainable instead you should use useEffect let me demonstrate by code in functional component.

//cildComponent.js
export default ChildComponent(props){
const [pending , setPending] = useState(true)
useEffect(()=>{
 if(props.name){
// now you have the name available
 setPending(false);
}
 },[props])
if(pending){
 return “loading”
 }
 return ‘your name is ${props.name}’
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!