SwitchButton.jsx 628 B

1234567891011121314151617181920212223
  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 style={{bottom: 5,
  12. position:'absolute'}}>
  13. <label>Show users infobar</label>
  14. <Switch {...label} size="small" defaultChecked onChange={() => handleChange()} />
  15. </div>
  16. )
  17. }