我正在开发一个 react native android 应用程序。我想获取当前的 ReactNativeApplication 实例,人们使用 com.facebook.react.common.ApplicationHolder.getApplication()
来获取应用程序实例,但现在这个方法已被弃用,所以现在有没有其他选择?
最佳答案
我也有同样的疑问。目前我正在使用类似的东西
// 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(/*...*/)
}
}
没有什么优雅,但它有效。
关于android - 如何在 react native android native 代码中获取应用程序实例?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50869556/