function
Source: Context.tsx ↗
useTheme()
Hook for reaching the theme from context.
useTheme: (theme?: ITheme) => ITheme | undefined
Parameters
Parameter | Type | Description |
|---|---|---|
theme | (Optional) theme to use instead of context value. If undefined, the context value is used. |
Returns
ITheme | undefined
Remarks
You can optionally set a theme override that will be returned if defined. This makes the usage more ergonomic (see the following example).
Example
// instead of
const fromContext = useTheme();
const effectiveTheme = fromArguments ?? fromContext.
// you can write
const theme = useTheme(fromArguments);