Skip to content

Component's re mounting for no reason #19

@chandu0101

Description

@chandu0101

Hi

class Test extends Component {
     render() {
        console.log('render test')
    return (
      <TouchableOpacity onPress={() => console.log('ok clicked')}>
       <Text> Click Me! </Text>
      </TouchableOpacity>
    );
  }
  componentWillReceiveProps(nextProps) {
    console.log("next props")
  }
}
export default class App extends Component {
  render() {
    return (
      <View>
        <Text> Parent Text </Text>
       <Test name={'hello'}> </Test>
      </View>
    );
  }
}

In above example when i click on "Click Me!" then

Expected :

ok clicked

Actual :

next props
render test
ok clicked

If i remove <Text> Parent Text </Text> from app then onPress is giving expected results looks like having more than one children is the issue(critical one)! ,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions