0

I had setup a ViewPager component in my react-native application which goes like this:

render(){
  return(
    <View>
       <ViewPager
         ref="main"
         dataSource={this.state.dataSource}
         renderPage={this.renderView}
       />
       <TouchableHighlight onPress={this._onPressButton}>
           <Text>Something</Text>
       </TouchableHighlight>     
    </View>  
  );
}

renderView(){
    return(
      <View ref="main1">
          <Text>Something else</Text>     
      </View>
    );
}

_onPressButton(){
    //Do something with {this.refs.main} and {this.refs.main1}
}

Now I want to access the node handle of View with main1 reference. I can find the node handle of ViewPager using findNodeHandle(this.refs.main) but this.refs.main1 returns null. How can find this child View's node handle?

Naman Sogani
  • 943
  • 1
  • 8
  • 28
  • May I know why you want main1 ref? – Jickson Jun 09 '16 at 06:35
  • 1
    I want to pass `main1` View to native Java code for creating its bitmap. For that I want find the node handle of the same View. – Naman Sogani Jun 09 '16 at 08:01
  • Sorry, for again repeating the same question. Why do you want to create bitmap using the view? Are you try something like this http://stackoverflow.com/a/3036736/2125612 ? – Jickson Jun 09 '16 at 08:33
  • I want to save the snapshot of that particular view. Thats why I need to access `main1` View – Naman Sogani Jun 09 '16 at 10:50

1 Answers1

0

I read somewhere that views which only contain one child are collapsed. It is entirely possible that that is what is happening in your case. I was able to force the view to not be collapsed by attaching a border to it. Obviously this isn't a solution, but it would at least tell you if that is what is happening.

Mobius
  • 2,871
  • 1
  • 19
  • 29