【发布时间】:2018-06-15 05:25:53
【问题描述】:
我正在开发一个 react native android 应用程序。我想获取当前的 ReactNativeApplication 实例,人们使用com.facebook.react.common.ApplicationHolder.getApplication() 获取应用程序实例,但是现在这种方法已被弃用,那么现在有什么替代方法吗?
【问题讨论】:
标签: android reactjs react-native
我正在开发一个 react native android 应用程序。我想获取当前的 ReactNativeApplication 实例,人们使用com.facebook.react.common.ApplicationHolder.getApplication() 获取应用程序实例,但是现在这种方法已被弃用,那么现在有什么替代方法吗?
【问题讨论】:
标签: android reactjs react-native
我也有同样的问题。目前我正在使用类似的东西
// imports up here
let app; // make a global variable
function calledFromiOSFramework() {
// the 'this' is not longer bound to the 'App'
console.log(app); // a working reference to 'App'
}
export default class App extends Component {
app = this;
render() {
return(/*...*/)
}
}
没什么优雅的,但它确实有效。
【讨论】: