SwitchButton.jsx 545 B

12345678910111213141516171819202122
  1. import Switch from '@mui/material/Switch';
  2. import { useDispatch } from 'react-redux';
  3. import { showUserInfoBox } from '../../reducers/userDataReducer';
  4. export const SwitchButton = () => {
  5. const label = { inputProps: { 'aria-label': 'Switch demo' } };
  6. const dispatch = useDispatch();
  7. const handleChange = () => {
  8. dispatch(showUserInfoBox())
  9. }
  10. return (
  11. <div>
  12. <label>Hide users</label>
  13. <Switch {...label} size="small" onChange={() => handleChange()} />
  14. </div>
  15. )
  16. }