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

92
Views
Child component not recognizing props change from parent component

I am working on an app and am having issues with Component C not recognizing a prop change from Component A. I have to pass the prop from Component A to Component B, and then down to Component C.

I removed a bunch of code from the snippets because these components are 400+ lines.

Component A looks like:

selectPeripheral = (peripheral, index) => {
    console.log(peripheral) 

    // what peripheral looks like
    // {"id":"27646F75-4D53-834F-BF94-4F1B975626CD","name":"LEDDMX-013176"}
    // or 
    // {"id":"8371C1D0-1F5A-EB7E-C83C-193A7BC26F7F","name":"LEDBLE-061E8A"}

    this.props.navigation.navigate('ColorPickerIndex', {
        screen: 'ColorPicker',
        params: {
            selectedPeripheral: peripheral
        },
    });
}

render() {
  {
    this.state.nearbyDevices.map((peripheral, index) => {
      return  <TouchableOpacity 
                key={`key-${index}`} 
                onPress={() => this.selectPeripheral(peripheral, index)}
               >
                  <Text>{peripheral.name}</Text>
                  <Text>LED light</Text>
               </TouchableOpacity>
     })
  }
}

Component B:

class ComponentB extends Component {
    constructor(props) {
        super(props);
        this.state = {
            selectedLight: this.props.route.params.peripheral
        }
}

render() {
  <ComponentC
      selectedPeripheral={this.state.selectedLight}
  />
}

Component C looks like:

const ComponentC = ({ selectedPeripheral }) => {

   return(
       <Text>{selectedPeripheral.name}</Text>
   )
}

This works only for the first peripheral. When I select a different peripheral, component C still shows the the first peripheral selected and not the different peripheral.

What can I do to update Component C with the new peripheral?

about 4 years ago · Juan Pablo Isaza
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!