在导航栏上使用自定义按钮反应通量

时间:2018-09-15 19:08:35

标签: javascript reactjs react-native

当我单击导航栏中的按钮时,由于存在不同的组件,如何传递页面数据(它是一种表单)。 我的导航栏像这样在我的app.js中:

<Scene
  key="tabhome"
  renderRightButton={<ButtonsHome/>}
  title="Publicaciones"
  icon={TabIcon}
  iconName="md-home">

您可以看到导航栏按钮是ButtonsHome组件,但是我在其他组件中有包含表单的页面。所以我的问题是,当我单击ButtonsHome中的按钮时,如何提交表单数据?

编辑:

app.js

<Router
  navigationBarStyle={{ backgroundColor: "#262628" }}
  titleStyle={{ color: "#FFF" }}
>
  <Scene key="root" hideNavBar>
    <Scene key="login" component={Login} initial hideNavBar />

    <Scene
      key="newPost"
      component={NewPost}
      hideNavBar={false}
      renderRightButton={<ButtonsHome />} //Here is where my button submit is.
      navBarButtonColor="#fff"
    />

    <Scene
      key="tabbar"
      tabs={true}
      tabBarStyle={{ backgroundColor: "#262628" }}
      tabBarPosition={"bottom"}
      showLabel={false}
      hideNavBar
    >
      <Scene
        key="tabhome"
        renderRightButton={<ButtonsHome />}
        title="Publicaciones"
        icon={TabIcon}
        iconName="md-home"
      >
        <Scene key="home" component={Home} />
      </Scene>

      <Scene
        key="tabprofile"
        renderRightButton={<ButtonsProfile />}
        title="Perfil"
        icon={TabIcon}
        iconName="md-person"
      >
        <Scene key="profile" component={Profile} />
      </Scene>
    </Scene>
  </Scene>
</Router>;

然后我有一个带有复选框,textInput和图片的NewPost组件。我想要的是console.log()这个数据,当我按下ButtonsHome内的按钮时,便拥有输入的数据。我该怎么办?

0 个答案:

没有答案