无法对模态(反应及以日期挑选)
因此,我们正在使用此lib react-native-date-picker
进行日期选择(显然)。
当用户从应用程序中超时时,我们将用户浏览回到登录屏幕。但是,如果打开日期选择器(这是模态),它将像往常一样保留在屏幕顶部。 库我认为没有任何选项可以决定何时应保持可见/无形的。
这是我尝试过的几种方法,没有成功
使用
forwardref
包装我的孩子组件(显示日期选择器),试图通过ref访问组件。没有成功,总是收到零作为回报。我认为图书馆也不支持这个?基于我们存储在redux的超时道具,在函数
componentDidupdate
中,我们通过将datePicker的propopen
as false设置为重新渲染屏幕。也没有成功。
我很好奇这是为什么发生的原因。可能的解决方案是什么?
So we are using this lib react-native-date-picker
for date picking (obviously).
When user is timeout from app, we are navigating the user back to login screen. However if the date picker (this is a modal) is opened, it will remain on top of screen as always. Within the library I see no option to decide when the modal should stay visible/invisible.
Here's few approaches I've tried with no success
Using
forwardRef
wrapping my child component (which shows the date picker), trying to access the component via Ref. No success, always receive NULL in return. I think the library don't support this either?Based on the timeout props we stored in Redux, within the function
componentdidupdate
we setState to re-render the screen by telling DatePicker's propopen
as FALSE. No success either.
Im curious on the reason behind why is this happening. What are the possible solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
React-Native-date-picker
使用每个平台使用相应的日期原始模块。打开本机模式时,当代码在JavaScript线程上运行时,它将在本机线程上运行。当用户会话过期并且应用程序导航到登录屏幕时,React Navigation试图卸载当前屏幕组件,但由于它在本机线程上运行,因此未安装Date Picker。
您的应用逻辑应检测到模态是否在导航到登录屏幕之前打开并关闭
react-native-date-picker
uses the corresponding Date picker native module for each platform. When the native modal is opened, it runs on the Native thread while your code runs on the JavaScript thread.When the user session expired and the app navigates to Login Screen, React Navigation tries to unmount the current screen component but Date Picker is not mounted because it runs on Native Thread.
Your app logic should detect if the modal is opened before and close it before navigating to Login screen