export const Focus = ({addSubject})=>{
const [tempValue, setTempValue] = useState(null);
return(
<View style={styles.container}>
<View style={styles.titleContainer}>
<Text style={styles.title}> What are you going to focus on....?</Text>
<View style={styles.inputcontainer}>
<TextInput style ={{flex:1, marginRight:10}}
onSubmitEditing ={
({nativeEvent}) => {
setTempValue(nativeEvent.text+'0000')
}
}
/>
<RoundedButton title ='+' onPress={
addSubject(tempValue)
}/>
</View>
</View>
</View>
);
}
就在输入数据之后,一旦点击‘Return’,提交就输入了"Text+0000"
但一旦替换为
<RoundedButton title ='+' onPress={
()=>{ addSubject(tempValue)}
}/>
在印刷机上不起作用
*我正在expo 网站上测试
出现这种行为的原因是什么?按下按钮后有什么解决方案使其工作.