1

I am using React Navigation and React Native Animatable, both awesome.

Is it possible to interact with another react component that is not its child? Like the below. I get an error

"Invariant Violation: React.Children.only expected to receive a single React element child."

handleViewRef = ref => this.view = ref;

bounce = () => this.view.bounce(800).then(endState => 
console.log(endState.finished ? 'bounce finished' : 'bounce cancelled'));

render(){
return (
<TouchableWithoutFeedback onPress={this.bounce}>
</TouchableWithoutFeedback>
<Animatable.View ref={this.handleViewRef}>
<Text>Bounce me!</Text>
</Animatable.View>
)
}

Let's say that I want to navigate the main view if I navigate, it would be cool to do this with:

<TouchableHighlight onPress={() => this.props.navigation.navigate('Home')} ><Text>Back</Text></TouchableHighlight>
4

0 回答 0