Skip to content

Commit

Permalink
- add isLoading for load components contacts
Browse files Browse the repository at this point in the history
  • Loading branch information
SoinRoma committed Jul 12, 2022
1 parent d06fb60 commit e1b6e0c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ const App = observer (() => {

useEffect(() => {
if(localStorage.getItem('refresh_token')){
users.setIsLoading(true);
checkAuth().then((data) => {
if (data.response) {
auth.setIsAuth(false);
} else {
auth.setIsAuth(true);
}
users.setIsLoading(false);
});
} else {
auth.setIsAuth(false);
Expand All @@ -26,6 +28,10 @@ const App = observer (() => {
// eslint-disable-next-line
}, [])

if(users._isLoading){
return <div />
}

return (
<BrowserRouter>
<AppRouter/>
Expand Down
5 changes: 5 additions & 0 deletions src/store/ContactStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@ import {makeAutoObservable} from "mobx";
export default class ContactStore {
constructor() {
this._users = [];
this._isLoading = false;
makeAutoObservable(this);
}

setUsers(contacts) {
this._users = contacts;
}

setIsLoading(bool){
this._isLoading = bool;
}

get getUsers() {
return this._users;
}
Expand Down

0 comments on commit e1b6e0c

Please sign in to comment.