javascript - react native router flux 遇到两个 child 用同一个key

标签 javascript modal-dialog react-native router flux

版本

  • 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/

相关文章:

javascript - react-native-maps 无法在无状态组件中引用 MapView

javascript - loopback-storage-component 如何显示图片-文件

javascript - Vue 中使用的 Momentjs 显示 UTC 时间,但应为本地时间

javascript - Date.UTC() 返回上个月的最后一天,而 getUTCFullYear()、getUTCMonth() 正确返回正确月份的第一天

ruby-on-rails - 无法从 http 页面显示 https 模式

reactjs - react native 中的动画可以暂停和重启吗?

javascript - 为什么在从 JavaScript 生成 HTML 时使用\x3C 而不是 <?

AngularJS,将数据传递给 stateProvider OnEnter 函数以填充模式

objective-c - 创建 float 通知 iOS 的最佳方式

javascript - 如何使用redux在react-native-router-flux中实现react-native-drawer?