mochixuan / react-native-smart-tip

🔥🔥🔥Toast , SnackBar , Modal , Show Toast above Modal
247 stars 37 forks source link

项目中使用react-native-root-siblings,则两者冲突。希望能解决。 #34

Closed MrTung closed 3 years ago

MrTung commented 3 years ago

import { RootSiblingParent } from 'react-native-root-siblings';

如上,项目里面也需要自定义一个全局弹出框,有用到RootSiblingParent,如果使用的话react-native-smart-tip就不能用。

"react": "16.13.1", "react-native": "0.63.2",

有谁知道怎么解决吗?

mochixuan commented 3 years ago

react-native-smart-tip里面已经引用了react-native-root-siblings。你不需要再引用react-native-root-siblings。

MrTung commented 3 years ago

我可能没说清楚,我的意思是我的项目里还自定义了一个全局的loading指示器组件,也用到'react-native-root-siblings'。

// in your entry file like App.js import { RootSiblingParent } from 'react-native-root-siblings';

// in your render function return (

// <- use RootSiblingParent to wrap your root component

);

这个是react-native-root-sibling的参考用法。 这样一写,我发现我写的全局loading组件和tip就只有一个有效。去掉上面的RootSiblingParent标签,tip就能正常显示,loading就不行。 加上RootSiblingParent标签,tip就不行,loading能正常显示。不知道为啥。

mochixuan commented 3 years ago

我本地测试了,去除代码的hide。都可以实现显示WToast同时显示多个。而且WToast也是也是使用react-native-root-siblings显示的, 你可以看下你本地有什么其他的限制。下面是我测试的版本

  "react": "16.13.1",
    "react-native": "0.63.2",
    "react-native-drag-sort": "2.3.4",
    "react-native-smart-tip": "^2.2.1"
Nokecy commented 3 years ago

用RootSiblingParent 包裹跟组件后WToast 就不会显示了 RN >0.62.0 @mochixuan

mochixuan commented 3 years ago

这个并没有遇到过,WToast不需要被包裹的