我觉得我陷入了循环
这里是我的孩子部(法院)
updateAfterTeamScoreGoal = () => {
if(this.state.teamScore >= this.state.teamScoreGoal) {
const newTrophyCount = this.state.trophyCount + 1;
this.setState((previousState) => ({
trophyCount: newTrophyCount,
teamScore: previousState.cloneTeamScore
}))
this.props.addTrophyToParent(this.props.navigation.state.params.teamName, newTrophyCount)
}
}
我正在尝试传递它以在我的父组件中的某处添加点
addTrophytoParent = (teamName, newTrophyCount) => {
return (
<Text>0</Text>
)
}
render() {
const { fontLoaded } = this.state;
return (
<ScrollView>
<TouchableOpacity
style={[styles.teamBox, { backgroundColor: "#094B93" }]}
onPress={this.goDallasTeam}>
<Court addTrophytoParent={this.addTrophytoParent}/>
<Image style={styles.trophyBox} source={nbaTrophy} />
<Text style={[styles.teamText, fontLoaded && { fontFamily: 'dallas', color: "#EAEAEA"}]}>Dallas</Text>
<Text style={[styles.scoreText, fontLoaded && { fontFamily: 'ncaa'}]}>{this.abbreviateNumber(this.state.dallasTeamScore)} / 5M</Text>
</TouchableOpacity>
我仅使用0来尝试使其正常工作,但是我得到的只是错误,这样做的正确方法是什么?