button loaders

This commit is contained in:
kurpfish
2021-08-18 16:18:11 +03:00
parent 288f060575
commit 8035687e2b
5 changed files with 33 additions and 20 deletions

View File

@ -1,14 +1,19 @@
import React from 'react';
import React, { useState } from 'react';
import { useDispatch } from 'react-redux';
import { Loader } from '../Loader/Loader';
import { auth } from '../../redux/outstaffingSlice';
import './logoutButton.css'
export const LogoutButton = () => {
const [isLoggingOut, setIsLoggingOut] = useState(false);
const dispatch = useDispatch();
return (
<div className='logout-button' onClick={()=>{localStorage.clear(); dispatch(auth(false));}}>
<button>Выйти</button>
<div className='logout-button'>
<button onClick={()=>{setIsLoggingOut(true); localStorage.clear(); dispatch(auth(false)); setIsLoggingOut(false); }}>
{
isLoggingOut ? <Loader /> : 'Выйти'
} </button>
</div>
)
}