Reputation: 2644
I need to call the method nameList(). It is the parent method. But it not worked for me. My code snipppet is below.
Below is my code snippet refer and any answer should be appreciated. I need the clarification about this
nameList = refName => () => {
if(!nameList){
get call
}
else(){
update call
}
}
renderNamesRight(selectedName) {
if (selectedNames.length > 0 ) {
return(
this.renderCenterNames()
)
}
}
renderCenterNames(){
if (!this.state.pressedCenterNames) {
return(
<TouchableOpacity onPress = {()=> this.validateInputFields()} activeOpacity = { .5 }>
<Text style = {styles.names}>CENTER NAMES</Text>
</TouchableOpacity>
)
} else {
return(
<Text style = {styles.names}>RIGHT NAMES</Text>
)
}
}
validateInputFields() {
const { validation} = this.state;
if (this.state.name) {
alert("validation")
validation.isFormValid = true;
this.setState({validation: validation});
this.nameList("name")
} else {
validation.isFormValid = false;
this.setState({validation: validation});
}
}
Upvotes: 0
Views: 29
Reputation: 383
This not the way you define a function. If you need a function with no parameter you have to define like this FunctionName = () => {}
or with parameters FunctionName = (parameters) => {}
.
If there is only one parameter in a function you can also declare it without ( ) like this FunctionName = parameter => {}
Replace your method definition
nameList = refName => () => {
with this
nameList = (refName) => {
Upvotes: 2