Simulate airplane mode in iPhone Simulator

前端 未结 4 1233
小蘑菇
小蘑菇 2021-01-31 06:29

Is there any way to simulate airplane mode in the iPhone Simulator?

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-31 07:18

    Easier hack : make a function checking the connection

    import NetInfo from '@react-native-community/netinfo';
    
    export const ckeckIsConnected = async () => {
      const isConnected = NetInfo.fetch().then((state) => {
        return state.isConnected;
      });
      return isConnected;
    };
    

    Do your data fetching only if there is connection. To simulate no connection, just return false to this function whatever the real connection is.

提交回复
热议问题