Reputation: 520
I can't solve this problem. Can you help me. evaluating 'this.props.speciesSelection.modalize'
<BarcodeInput
speciesSelection={this.props.speciesSelection}
species={species[0]}
barcode={{ manufacturerValue: "", codeValue: "" }}
onChangeText={this.onChangeText}
/>
class BarcodeInput extends React.Component<Props, State> {
onPrefixPress = () => {
Keyboard.dismiss();
this.props.speciesSelection.modalize.open();
this.props.speciesSelection.modalizeOpened = true;
}
Red Box when I touch to button onPrefixPress
Upvotes: 1
Views: 289
Reputation: 1194
It looks like you are trying to invoke a function (passed via props) which is undefined.
Make speciesSelection
prop optional.
interface Props {
species: Species;
barcode: BarcodeState;
speciesSelection?: any;
onChangeText: (prop: keyof BarcodeState, value: string) => void;
}
interface State { }
class BarcodeInput extends React.Component<Props, State> {
onPrefixPress = () => {
Keyboard.dismiss();
this.props.speciesSelection && this.props.speciesSelection.modalize.open();
this.props.speciesSelection && this.props.speciesSelection.modalizeOpened = true;
}
or check why it's undefined.
Upvotes: 1