Stop Activity indicator animation when server is not connected

オープン
#21 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
20/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
javascript, react-native
領域
mobile-dev

調査の方向性

貼り付けられたログインのfetchフローから始め、特にloaderの状態とcatchハンドラーを確認してください。リポジトリでreact-native-loaderがどのように使用されているか、またネットワーク障害によってインジケーターがリセットされるか、alertが表示されるかを確認してください。切断されたサーバーに対して要求された動作が定義され、検証されれば、issueは完了です。

索引モデルが issue の本文から書いたものです。

説明

Hi,

You can find my Login screen API code below. I am using Activity indicator animation which is working fine, whenever the button is pressed. Once the user inputs(username & password) match with the API data correctly, the screen will be navigated to Home screen. Problem with the code is, i just want to stop the loader animation when server(API) is not connected. Or i want to show some alert message about server connection, whenever the app launches.

I am new React native. Kindly share your ideas.

        {
            this.setState({
                errorUsername:'',
                errorPassword:'',
                loader:true,
                loggedIn:this.props.receiveState //RECEIVE VALUE FROM REDUCER
            })
            await fetch(LOG_IN_URL,{
                method: 'POST',
                headers: new Headers({'content-type': 'application/json'}),
                body: JSON.stringify({"userId": this.state.username, "password": this.state.password})
                })
                .then(function (response) {  
                    return response.json();
                })
                .then((responseJson) => {
                    console.log("LOGGED IN SUCCESS OR FAILURE:::::::::"+JSON.stringify(responseJson));
                    if(responseJson.status === 'success')
                    {
                        const userToken = responseJson.data.userSession;
                        AsyncStorage.setItem('userSession', userToken)
                        console.log('ASYNC STORAGE VALUE IS SET::::::'+JSON.stringify(userToken));
                        this.setState({ 
                            loggedIn: true,
                            errorPassword:'',
                            errorUsername:'',
                            username:'',
                            password:'',
                            loader:false
                        })
                        this.props.sendState(this.state.loggedIn); //SEND VALUE TO REDUCER
                    }
                    else
                    {
                        this.refs.customToast.show('Invalid Details', DURATION.LENGTH_LONG);
                    }
                    })
                .catch(function (error) {
                    this.setState({loader:false})
                    this.refs.customToast.show('Check Network Connection', DURATION.LENGTH_LONG);
                    console.log("ERROR CAUGHT::::::::"+error);
                });
            this.state.loggedIn === true ? this.props.navigation.navigate('Home') : ''
        }
    }
主要言語
JavaScript
スター
390
フォーク
63
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

mohebifar/react-native-loader のほかの issue

mohebifar/react-native-loader の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。