我正在开发一个本机应用程序,并且在理解代码的某些部分时遇到了一些问题。特别 容器和商店概念。
如果任何人都可以向我解释这些概念,并且这本代码指南有效,我将不胜感激。
const CONTAINERS = {}
function addContainer(key,klass,...args) {
CONTAINERS[key] = new klass(...args) // eslint-disable-line
CONTAINERS[key].containers = CONTAINERS
}
addContainer('auth',AuthContainer)
addContainer('activities',activitiesContainer)
const CONTAINERS_TO_INJECT = Object.keys(CONTAINERS).map(
(key) => CONTAINERS[key]
)
export default class App extends Component {
componentDidmount() {
this.appState = AppState.currentState
AppState.addEventListener('change',this._handleAppStateChange);
}
componentWillUnmount() {
AppState.removeEventListener('change',this._handleAppStateChange);
}
_handleAppStateChange = nextAppState => {
if (this.appState.match(/inactive|background/) && nextAppState === 'active') {
this.nowTime = new Date().getTime()
} else {
const openTime = (new Date().getTime()-this.nowTime)/1000
};
state = {
isAppReady: false,issplashReady: false,}
_cacheSplashResourcesAsync = async () => {
const images = [
require('./assets/images/splash.jpg'),require('./assets/images/logo-IH_blue_gold.png'),]
return cacheImages(images)
}
render() {
if (!this.state.issplashReady) {
return (
<AppLoading
startAsync={this._cacheSplashResourcesAsync}
onFinish={() => this.setState({ issplashReady: true })}
onError={console.warn}
autoHideSplash
/>
);
}