Skip to content

Commit

Permalink
Merge pull request #4 from lizaklimova/theme-switch
Browse files Browse the repository at this point in the history
added types to useStates
  • Loading branch information
lizaklimova authored Jan 14, 2024
2 parents 20f0129 + 2e0b4cc commit 445879c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/components/Header/ToggleBtn/ToggleBtn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import useTheme from 'hooks/useTheme';

const ToggleBtn: FC = () => {
const { theme, toggleTheme } = useTheme();
const [checked, setChecked] = useState(theme === 'light' ? true : false);
const [checked, setChecked] = useState<boolean>(
theme === 'light' ? true : false
);

const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
setChecked(event.target.checked);
Expand Down
2 changes: 1 addition & 1 deletion src/contexts/themeContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const defaultContextValue: ThemeContextProps = {
const ThemeContext = createContext<ThemeContextProps>(defaultContextValue);

const ThemeProvider: FC<ThemeProviderProps> = ({ children }) => {
const [theme, setTheme] = useState(() => {
const [theme, setTheme] = useState<string>(() => {
const storedTheme = localStorage.getItem('theme');
return storedTheme ? JSON.parse(storedTheme) : 'light';
});
Expand Down
1 change: 0 additions & 1 deletion src/routes/index.ts

This file was deleted.

0 comments on commit 445879c

Please sign in to comment.