Fakefish
Fakefish

Reputation: 315

why I change the navigator props execute twice handler?

here is my View to switch page

this.props.navigator.push({
  component: QuestionDetail,
  passProps: {
    id: id,
    enteredDetail: function() {
      console.log(this)
    }
  }
});

// in QuestionDetail
render: function() {
  this.props.enteredDetail();
....

in Xcode I saw this

RCTJSLog> {"navigator":{},"route":{"passProps":{"id":"1010000002652090"}},"id":"1010000002652090"}
RCTJSLog> {"navigator":{},"route":{"passProps":{"id":"1010000002652090"}},"id":"1010000002652090"}

it appear twice! why?

Upvotes: 0

Views: 372

Answers (1)

Colin Ramsay
Colin Ramsay

Reputation: 16476

See this issue:

https://github.com/facebook/react-native/issues/151

in order for the react diffing algorithm to correctly reset properties back to their default state, we create a single dummy "defaultView" for every type of view

Upvotes: 2

Related Questions