版本
- react-native-router-flux v3.31.2
- react-native v15.2.1
我不知道我做错了什么,但是当我尝试多次调用 Actions.dialog()
时,我收到了这个错误。
我认为这个修复 https://github.com/aksonov/react-native-router-flux/issues/327修复了它,但它不是,它应该是别的东西,但我没有想法......
唯一一次我没有这个,是当我使用 pop() 关闭它的时候。不幸的是,我不想弹出(它可能会破坏我应用程序中的其他功能)。
有人可以帮忙吗?
错误:
`1:$dialog_1_dialog`. Child keys must be unique; when two children share a key, only the first child will be used.
in RCTView (created by View)
in View (created by Modal)
in Modal (created by DefaultRenderer)
in RCTView (created by View)
in View (created by DefaultRenderer)
in DefaultRenderer (created by SceneView)
in SceneView (created by NavigationCard)
in RCTView (created by View)
in View (created by AnimatedComponent)
in AnimatedComponent (created by NavigationCard)
in NavigationCard (created by Container)
in Container (created by NavigationComponent)
in NavigationComponent (created by NavigationAnimatedView)
in RCTView (created by View)
in View (created by NavigationAnimatedView)
in RCTView (created by View)
in View (created by NavigationAnimatedView)
in NavigationAnimatedView (created by NavigationComponent)
in NavigationComponent (created by DefaultRenderer)
in DefaultRenderer (created by NavigationRootContainer)
in NavigationRootContainer (created by Router)
in Router (created by Connect(Router))
in Connect(Router) (created by CdiscountReact)
in Provider (created by CdiscountReact)
in CdiscountReact
in RCTView (created by View)
in View (created by AppContainer)
in RCTView (created by View)
in View (created by AppContainer)
in AppContainer
2016-08-08 14:23:04.269 [warn][tid:com.facebook.react.JavaScript] Warning: flattenChildren(...): Encountered two children with the same key, `1:$dialog_2_dialog`. Child keys must be unique; when two children share a key, only the first child will be used.
in RCTView (created by View)
in View (created by Modal)
in Modal (created by DefaultRenderer)
in RCTView (created by View)
in View (created by DefaultRenderer)
in DefaultRenderer (created by SceneView)
in SceneView (created by NavigationCard)
in RCTView (created by View)
in View (created by AnimatedComponent)
in AnimatedComponent (created by NavigationCard)
in NavigationCard (created by Container)
in Container (created by NavigationComponent)
in NavigationComponent (created by NavigationAnimatedView)
in RCTView (created by View)
in View (created by NavigationAnimatedView)
in RCTView (created by View)
in View (created by NavigationAnimatedView)
in NavigationAnimatedView (created by NavigationComponent)
in NavigationComponent (created by DefaultRenderer)
in DefaultRenderer (created by NavigationRootContainer)
in NavigationRootContainer (created by Router)
in Router (created by Connect(Router))
in Connect(Router) (created by CdiscountReact)
in Provider (created by CdiscountReact)
in CdiscountReact
in RCTView (created by View)
in View (created by AppContainer)
in RCTView (created by View)
in View (created by AppContainer)
in AppContainer
代码
<Scene key="modal" component={Modal} >
<Scene key="root">
<Scene key="launch" initial={true} component={Launch} />
...
</Scene>
{/*Modals*/}
...
<Modal key="dialog" component={Dialog} direction="vertical"/>
</Scene>
最佳答案
希望能帮到你:
<Modal key="dialog" clone component={Dialog} direction="vertical"/>
关于javascript - react native router flux 遇到两个 child 用同一个key,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38831596/