小编bai*_*ang的帖子

react-native undefined不是对象(评估RCCManager.setRootController)

我正在尝试使用redux和redux-saga绑定创建一个简单的react-native应用程序.不幸的是,当我尝试运行应用程序时(无论是使用react-native run-ios还是运行Xcode,我都会收到以下错误:

错误消息:undefined不是对象(评估'RCCManager.setRootController')

奇怪的是,当我将诸如redux-saga的Counter示例移植到本地或其他示例的反应时,我没有这个问题.我想知道是否有人可以指出事情可能出错的地方?

ios reactjs react-native redux redux-saga

8
推荐指数
1
解决办法
2286
查看次数

React-redux在mapDispatchToProps中获取道具或状态

请原谅潜在的noob问题,我是新的反应和反应 - redux.

我有一个代表当前登录屏幕的组件.它的一个道具是"登录",一个包含电子邮件和密码的字典.定义组件后,我使用react-redux库将其与商店连接,如下所示:

const mapStateToProps = (state) => {
  return {
    rootNav: state.rootNav,
    login: state.login,
  };
};

const mapDispatchToProps = (dispatch, ownProps) => {
  return {
    onLoginClick: () => {
      // TODO: actually get the login credentials from the view
      dispatch(actions.submitLogin('testuser', 'testpw'));
      dispatch(actions.changeRootNav(rootNavs.OVERVIEW_NAV))
    },
    onEmailUpdate: (email) => dispatch(actions.updateEmail(email)),
    onPasswordUpdate: (password) => dispatch(actions.updatePassword(password)),
  };
};
Run Code Online (Sandbox Code Playgroud)

显然,在这行中dispatch(actions.submitLogin('testuser', 'testpw'));我希望将真实的电子邮件和密码作为有效负载提交给动作.但我不明白我应该如何从组件中访问它(即我不能只使用this.props.login)或者是否应该从商店访问它(我将在哪里通过商店?)

任何澄清都会非常有帮助!

reactjs redux react-redux

6
推荐指数
1
解决办法
5802
查看次数

Python time.perf_counter()返回的小数秒到底是多少?

这可能是一个愚蠢/明显的问题,但只是想确保我的预感是正确的.

我正在使用time.perf_counter()在Python3脚本中执行一些基本的性能计时,如下所示:

start = time.perf_counter()
# some time consuming operation here
end = time.perf_counter()
elapsed = end - start
Run Code Online (Sandbox Code Playgroud)

我会得到像9.774或36.903这样的值(当然还有更多的小数位).我假设数字越大=时间越长,但这些数字到底意味着什么呢?例如,1.23小秒仅1秒和0.23分秒

python time timing python-3.x

5
推荐指数
1
解决办法
2225
查看次数