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

120
Views
How to pass props on react-redux component?

props aren't defined in my app is throwing an undefined error. Once the state is defined, it doesn't rerender the component with the new props.

  render(){
    // console.log("RENDER PROPS", this.props)
    const  { name, category, price, img} = this.props

    return(
      <div>
        <h2>={name}/>
        <h4>{category}/>
        <h3>{price}</>
        <img={img}/>
      </div>
    )
  }
}
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

you should save props in inner state in the component see the example.

export default function Page({ nameFromProps , ageFromProps }) => {
    const [name , setName] = useState(nameFromProps );
    const [age, setAge] = useState(ageFromProps );
   useEffect(() => {
      setName(nameFromProps);
      setAge(ageFromProps);
   },[nameFromProps]);
  return (<div> Data : {name}{age} </div>)
}
about 4 years ago · Juan Pablo Isaza Report

0

It is not very clear that how you pass props to the component , maybe there is mistake in this step , but for check you can use

  shouldComponentUpdate(nextProps, nextState) {
    if (this.props.color !== nextProps.color) {
      return true;
    }
    if (this.state.count !== nextState.count) {
      return true;
    }
    return false;
  }

to check your props value and force to re render or not

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!