1
DB.users.get_all(function(response){
  this.setState(result: response); // not required
  return response // required but not working for react-native-db-model
});

我可以从这个方法返回响应。我正在使用 react-native-db-model 而不是在 setState() 方法中设置响应。任何其他建议将不胜感激。

提前致谢。

4

1 回答 1

1

据我阅读的源代码react-native-db-models,函数get_all没有返回任何内容,而只是执行回调(https://github.com/darkrisabh/react-native-db-models/blob/master/index.js#L44

因此,您不能返回对变量的响应。因此,使用setState()将是 IMO 的最佳选择。

于 2016-07-27T08:24:38.867 回答