()
| 6 | import {useEffect, useState} from "react"; |
| 7 | |
| 8 | export default function ThemeToggle() { |
| 9 | const {theme, setTheme} = useTheme(); |
| 10 | const [mounted, setMounted] = useState(false); |
| 11 | |
| 12 | useEffect(() => { |
| 13 | // eslint-disable-next-line react-hooks/set-state-in-effect |
| 14 | setMounted(true); |
| 15 | }, []); |
| 16 | |
| 17 | if (!mounted) return null; |
| 18 | |
| 19 | return ( |
| 20 | <Button |
| 21 | color='primary' |
| 22 | variant='light' |
| 23 | isIconOnly |
| 24 | aria-label='Toggle Theme' |
| 25 | onPress={() => setTheme(theme === 'light' ? 'dark' : 'light')} |
| 26 | > |
| 27 | {theme === 'light' ? ( |
| 28 | <MoonIcon className='h-8' /> |
| 29 | ) : ( |
| 30 | <SunIcon className='h-8 text-yellow-300' /> |
| 31 | )} |
| 32 | </Button> |
| 33 | ); |
| 34 | } |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…