为什么这个空组件仍在渲染

时间:2021-07-21 16:16:40

标签: javascript react-native

我构建了一个解析屏幕,用于检查密钥的异步存储,如果该密钥为真,它会将您导航到一个或另一个屏幕。它呈现请求位置模式 1 秒,然后它消失,只显示一个白屏,它是空组件。为什么它只显示组件一秒钟?

import { Component } from 'react';
import { concessionTypes } from '@white-shell/global/globalParameters';
import LocalCache from '../../helpers/localCache';


class ResolveRequestLocationScreen extends Component {
  async componentDidMount() {
    const { navigation } = this.props;
    const wasRequestLocationShown = await LocalCache.getWasRequestLocationShown() || null;

    if (wasRequestLocationShown) {
      return navigation.navigate('ConcessionDashboard', {
        concessionType: concessionTypes.food,
      });
    }
    return navigation.navigate('RequestLocationModal');
  }

  render() {
    return null;
  }
}

export default ResolveRequestLocationScreen;

0 个答案:

没有答案
相关问题