我对本机反应(博览会)中的模态有一个奇怪的问题。我的模态看起来像这样:
const useNewCommentModal = () => {
const [showModal, setShowModal] = useState(false);
const [comment, setComment] = useState('');
const toggle = () => {
setShowModal(!showModal);
};
const NewCommentModal = () => (
<Modal visible={showModal} animationType="slide">
<View style={[t.pX4]}>
<TextInput
style={[t.bgWhite, t.p2, t.rounded, t.textLg]}
placeholder={'Post jouw reactie...'}
onChangeText={text => setComment(text)}
value={comment}
/>
</View>
</Modal>
);
return [toggle, NewCommentModal];
};
export default useNewCommentModal;
当我键入时,模态不断重新打开。当我删除它时:
onChangeText={text => setComment(text)}
问题消失了,但显然状态不再更新。为什么模型不断重新打开?
- 编辑 -
const [toggleModal, NewCommentModal] = useNewCommentModal(
'user',
route.params.user.id
);
<NewCommentModal />
呼如林
眼眸繁星
随时随地看视频慕课网APP
相关分类