React-Native StackNavigator

时间:2017-05-20 20:45:21

标签: javascript react-native navigation react-redux

好的,所以我有一个问题,我是新的反应原生开发并且遇到了StackNavigator的问题。当我按下一个用于导航当前屏幕的按钮时,它会给我一个像这样的错误: enter image description here

这是我正在使用的代码,我无法让它工作,

select 
  count(*) as total,
  count(case when g_y_loc between 0 and 5 then 1 end) as cnt_pos,
  count(case when g_y_loc between -5 and 0 then 1 end) as cnt_neg,
  count(case when g_y_loc between 0 and 5 then 1 end) / count(*) * 100 as prz_pos,
  count(case when g_y_loc between -5 and 0 then 1 end) / count(*) * 100 as prz_neg
from goals;

2 个答案:

答案 0 :(得分:0)

在渲染功能中,你必须像这样提取导航器:

if (file_exists('first.txt') {
    unlink('first.txt');
    // and do some other stuff
}
echo 'whatever';

开始使用堆栈导航:

render()
{
  const { navigate } = this.props.navigation;
  return (
    <Button
      onPress={() => navigate('News')}
      title="News"
    />
  )
}

干杯:)

答案 1 :(得分:0)

如果您确实尝试从创建它的组件导航,则无法访问导航器,因为它只会向NewsApp内的任何内容注入导航。

您应该在导航堆栈中最顶层组件内处理背压。但是,如果您需要控制导航,例如您所拥有的导航,那么也许实施redux将是一个很好的解决方案。