【问题标题】:Prevent React Native App running until it has been updated with code-push阻止 React Native App 运行,直到它被代码推送更新
【发布时间】:2017-08-22 10:02:14
【问题描述】:

我想知道是否有可能阻止用户访问应用程序中的任何屏幕,直到代码推送更新,这可能吗?如果可能的话,请你给我看一个例子,目标是在下载更新之前阻止应用程序启动。

【问题讨论】:

    标签: android react-native code-push react-native-code-push


    【解决方案1】:

    您使用loading 之类的状态来记录是否已下载更新。 在render() 中,仅当loading 为false 时才返回正常的应用内容。请参阅下面的代码。

    componentDidMount() {
      this.setState({loading: true});
      fetch(url).then(() => this.setState({loading: false})
    }
    
    render() {
      const {loading} = this.state;
      return (
        {loading && <Text>Loading</Text>}
        {!loading && <View>You normal app content</View>}
      )
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-12-24
      • 1970-01-01
      • 2020-02-21
      • 2018-05-13
      • 2018-10-29
      • 1970-01-01
      • 1970-01-01
      • 2019-08-27
      相关资源
      最近更新 更多