button loaders
This commit is contained in:
@ -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>
|
||||
)
|
||||
}
|
Reference in New Issue
Block a user