【发布时间】:2020-01-17 10:55:06
【问题描述】:
当应用程序在后台运行时,我想使用“react-native-background-task”组件调用componentDidMount() 或任何其他函数。这是我想使用但不知道是否正确的代码:
import BackgroundTask from 'react-native-background-task'
BackgroundTask.define(async () => {
this.componentDidMount();
BackgroundTask.finish();
});
export default class MyClass extends Component {
componentDidMount() {
this.someTask();
}
}
【问题讨论】:
标签: reactjs react-native background-task