I have a ScrollView in a native answer and it has many Views. I save the ref for viewing with the following code
cards.push( <Card ref={(ref) => { console.log(ref); this.cardRef[index] = ref; ref.testMethod(); }} /> );
A map is a separate component that looks like this:
class Card extends Component { constructor(props) { super(props); this.testMethod = this.testMethod.bind(this); } testMethod() { console.log('this.is.test.method'); } render() { return ( <View style={styles.container}> <Text>This.is.a.card</Text> </View> ) } }
However, he says that testMethod is not defined, cannot call ref.testMethod ().
source share