Usestate挂钩不会在自定义事件上更新状态(React Native)

时间:2020-02-17 14:43:09

标签: javascript reactjs react-native mobile

你好社区, 我正在尝试使用react useState挂钩设置状态。在其他任何地方都可以正常工作。但是,对于此组件,我不了解发生了什么错误。状态未更新。使用静态数据更新状态也不起作用。在useEffect块内设置的其他状态正在初始渲染和重新渲染时完美更新。所有帮助将不胜感激。

      if (age < 18 && age1 < 18 && age2 < 18 || age > 3 && age1 > 3 && age2 > 3){
      Console.WriteLine("Everyone got into the playground today!");
    } else if(age > 18 && age1 > 18 && age2 > 18 || age < 3 && age1 < 3 && age2 < 3)){
      Console.WriteLine("No one got into the playground today!");
    } else if(age1 > 18 && age2 > 18 || age1 < 3 && age2 < 3){
      Console.WriteLine(name1 + " and " + name2 + " Couldn't get into the playground today");
    }

TSX where 'getYaxis' method is being called through onLayout prop.

Generating the Y Axis co-ordinate of the component and trying to set the state.

Logging the output

0 个答案:

没有答案