【问题标题】:I need to call the `componentWillMount` of a page我需要调用页面的 `componentWillMount`
【发布时间】:2017-09-10 04:49:00
【问题描述】:

我正在使用"react-native-router-flux": "^3.38.0"。我需要调用页面的componentWillMount,但在它第一次到达那里之后,componentWillMount 不会被调用。

版本:

请在下面找到导航代码:

const RouterComponent = () => {
  return (
    <Router sceneStyle={{ paddingTop: 65 }} navigationBarStyle={{ backgroundColor: '#81b71a' }}>

      <Scene key='auth' initial>
        <Scene key='login' component={LoginForm} title='login here' />
      </Scene>

      <Scene key='main' >
        <Scene key='employeeCreate' component={EmployeeCreate} title='create employee' />
        <Scene
        initial
          key='employeeList'
          component={EmployeeList}
          title='Emplyees'
          rightTitle='add'
          onRight={() => Actions.employeeCreate()}
        />
        <Scene
          key='employeeEdit'
          component={EmployeeEdit}
          title='edit employee'
        />
      </Scene>
    </Router>
  );
};

export default RouterComponent;

【问题讨论】:

  • 你能分享你用于导航的代码吗?
  • @DanPhilip 已编辑

标签: reactjs react-native react-native-router-flux


【解决方案1】:

这是 v3.38 中的一个已知问题,已在更高版本中修复。尝试将软件包更新到最新版本。 Issue

4.0.0-beta.21 是最新的

【讨论】:

  • 4.0.0 让我解决了其他问题,我被要求搬回 38
  • 您究竟需要componentWillMount 做什么?也许有一个解决方法。
  • 每当显示该页面时,我都需要调用动作创建者。
  • 是的,但它不起作用,因为我需要在页面启动时只调用一次操作
猜你喜欢
  • 1970-01-01
  • 2014-02-21
  • 2020-07-04
  • 1970-01-01
  • 1970-01-01
  • 2016-08-25
  • 1970-01-01
  • 1970-01-01
  • 2017-06-29
相关资源
最近更新 更多