Skip to content

componentWillMount, componentWillReceiveProps and render being called twice times  #16806

@Kottidev

Description

@Kottidev

Is this a bug report?

Yes

Bug

I created new app with react-native-init ,

and i added log to know it's a bug from react-native or from my code ;

export default class App extends PureComponent<{}> {
  componentWillMount() {
    console.log('componentWillMount');
  }
  componentDidMount() {
    console.log('componentDidMount');
  }
  componentWillReceiveProps() {
    console.log('componentWillReceiveProps');
  }
  render() {
    console.log('render')
    return (
      <View style={styles.container}>
        <Text style={styles.welcome}>
          BUG WITH React Native!
        </Text>
      </View>
    );
  }
}

This is the result of log :

2017-11-13 09:37:41.369 [info][tid:com.facebook.react.JavaScript] componentWillMount
2017-11-13 09:37:41.368865+0100 myapp[14909:120213] componentWillMount
2017-11-13 09:37:41.369 [info][tid:com.facebook.react.JavaScript] render
2017-11-13 09:37:41.369192+0100 myapp[14909:120213] render
2017-11-13 09:37:41.378 [info][tid:com.facebook.react.JavaScript] componentDidMount
2017-11-13 09:37:41.378381+0100 myapp[14909:120213] componentDidMount

Environment

Environment:

OS: macOS Sierra 10.12.6
Node: 6.11.2
Yarn: 1.3.2
npm: 5.5.1
Watchman: 4.7.0
Xcode: Xcode 9.1 Build version 9B55
Android Studio: 2.3 AI-162.4069837

Packages: (wanted => installed)
react: 16.0.0 => 16.0.0
react-native: 0.50.3 => 0.50.3

Target Platform: iOS (10.3)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions