refact: convert components to use React.FC type + type improvements

This commit is contained in:
Phi
2019-09-17 17:06:43 -04:00
committed by Jean-Philippe Sirois
parent d61c218657
commit 1d88367645
23 changed files with 89 additions and 74 deletions
+6 -7
View File
@@ -1,23 +1,22 @@
import React, { createContext, useMemo } from "react"
import React, { createContext, FC, useMemo } from "react"
import { ThemeProvider as BaseThemeProvider } from "styled-components"
import { darkTheme, lightTheme } from "./design/themes"
import { useLocalStorage } from "./hooks/useLocalStorage"
interface IThemeProviderProps {
// TODO: type this properly, BaseThemeProvider doesn't like React.ReactNode
children: any
}
export interface IThemeContext {
theme: "dark" | "light"
setTheme: () => void
toggleTheme: () => void
}
interface IScopedDownChildren {
children: JSX.Element
}
export const ThemeContext = createContext<IThemeContext | null>(null)
const ThemeProvider = ({ children }: IThemeProviderProps) => {
const ThemeProvider: FC<IScopedDownChildren> = ({ children }) => {
const [theme, setTheme] = useLocalStorage("theme", "light")
const themeObject = useMemo(