KodersLab / react-native-for-web

A set of classes and react components to make work your react-native app in a browser. (with some limitations obviously)
MIT License
255 stars 17 forks source link

Component's re mounting for no reason #19

Open chandu0101 opened 8 years ago

chandu0101 commented 8 years ago

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)! ,

chandu0101 commented 8 years ago

my relay app is almost non functional :( , @mattiamanzati any idea on why its happening ? :s

ghost commented 8 years ago

This is really strange. Maybe it is due to onLayout Handling? Can you please try adding a console.log on utils/onLayout and see How it behaves? I am not able to reproduce it atm :/

----- Messaggio originale ----- Da: "Chandra Sekhar Kode" notifications@github.com Inviato: ‎23/‎11/‎2015 10.41 A: "KodersLab/react-native-for-web" react-native-for-web@noreply.github.com Oggetto: Re: [react-native-for-web] Component's re mounting for no reason(#19)

my relay app is almost non functional :( , @mattiamanzati any idea on why its happening ? :s — Reply to this email directly or view it on GitHub.

chandu0101 commented 8 years ago

i'll debug tomorrow early morning in my time, meanwhile here is the sample to reproduce https://github.com/chandu0101/rn-web-error