Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all articles
Browse latest Browse all 28469

React native understand Container and Store

$
0
0

I am working on a react-native app and have few issues understanding some parts of the code. especially the Container and the store concepts.

if anyone can explain to me those concepts and this spinet of code works I would greatly appreciate it.

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
        />
      );
    }

Viewing all articles
Browse latest Browse all 28469

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>