“ promisify”模态并等待分辨/拒绝(react Antial)
我对此软件包有一个问题: reaction-modal-promise 。它就像围绕模态周围的包装器,然后您可以将模态用作承诺。
一个示例:
MyModal().then(() => console.log('resolved!')).catch(() => console.log('rejected!'));
模态组件看起来像这样(简化!):
const MyModal = () => {
return (
<Modal>
<Pressable onPress={resolve}>
<Text>Resolve this modal</Text>
</Pressable>
<Pressable onPress={reject}>
<Text>Reject this modal</Text>
</Pressable>
</Modal>
);
};
如何在React Native中实现这一目标?我想将照片上传到我的服务器。当用户单击一个按钮时,我想打开一个模态,用户可以在其中选择照片并在模态解析后解析它,应上传照片。
我知道我可以在JSX代码中加入我的普通模态,但我对此软件包的工作方式感到好奇。
它是针对本地的。
I have a question about this package: react-modal-promise. It is like a wrapper around a modal, and then you can use the modal as a promise.
An example:
MyModal().then(() => console.log('resolved!')).catch(() => console.log('rejected!'));
The modal component would look like this (simplified!):
const MyModal = () => {
return (
<Modal>
<Pressable onPress={resolve}>
<Text>Resolve this modal</Text>
</Pressable>
<Pressable onPress={reject}>
<Text>Reject this modal</Text>
</Pressable>
</Modal>
);
};
How can I achieve this in react native? I want to upload a photo to my server. When the user clicks a button, I want to open a modal where the user can select a photo and resolve it, after the modal resolve, the photo should be uploaded.
I know I can include my normal modal inside the JSX code, but I am curious about how this package works.
It's for react native.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论