react-dual-theme
Version:
Theme context for React (Native) apps
27 lines (20 loc) • 471 B
Flow
/**
* @Author: Martin Adamko <martinadamko.sk@gmail.com>
* @Date: 2019-10-13T12:10:00+02:00
* @Copyright: Martin Adamko
* @flow
**/
import * as React from 'react'
import { ThemeContext } from './ThemeContext'
const emptyContext = [Object.freeze({
light: undefined,
dark: undefined,
})]
export function useTheme () {
const context = React.useContext(ThemeContext)
const [theme] = context || emptyContext
return [
theme.light,
theme.dark,
]
}