Just started react-native. So noob here but simple problem
The following idea (but stripped-down version below) works fine in my browser but in Android I get an error about the child function component not recognizing the prop function name. Any ideas on what I should do differently for Android?
Notice the parent has onSquarePress={squarePress}
and the child has <TouchableWithoutFeedback onPress={() => props.onSquarePress(props.notation)}>
parent:
import React, { Component, PropTypes } from 'react';
import { Text, View, StyleSheet, TouchableWithoutFeedback } from 'react-native';
import Square from './square';
const squarePress =(notation) => {
console.log(notation)
}
export default function Board(props) {
return (
<View>
<Square
key={..}
left={xOffset + i * squareSize}
top={yOffset + y * squareSize}
size={squareSize}
notation={notation}
onSquarePress={squarePress}
/>
</View>
);
}
child
mport React, { Component, PropTypes } from 'react';
import { Text, View, StyleSheet, TouchableWithoutFeedback } from 'react-native';
export default function Square(props) {
return (
<TouchableWithoutFeedback
onPress={() => props.onSquarePress(props.notation)}
disabled={false}
>
<View
key={props.notation}
>
</View>
</TouchableWithoutFeedback>
);
}
});
Any ideas would be very appreciated!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…