In my React Native app I have a class component Parent
and in it I define two functional components ChildA
and ChildB
. This works without errors:
class Parent extends Component {
const ChildA = () => {
return <View a={this.props.a} b={this.props.b} c={101}/>
}
const ChildB = () => {
return <View a={this.props.a} b={this.props.b} c={102}/>
}
}
I want to modularize this by creating GenericChild
like this:
class Parent extends Component {
const GenericChild = (props) => {
return <View a={this.props.a} b={this.props.b} c={props.c}/>
}
const ChildA = () => {
return <GenericChild c={101}/>
}
const ChildB = () => {
return <GenericChild c={102}/>
}
}
This throws the error Cannot read properties of undefined (reading 'apply')
.
What did I do wrong?