Advanced
Usage Guides
API Reference
fela-native
react-fela
jest-react-fela
Docs / API Reference / react-fela / ThemeContext
ThemeContext
ThemeContext is the internal instance of
React.createContext
that is provided by React's new context APIs. It is exposed to be used with React's new useContext hook.Note: Although it is exposed for react-fela as well as preact-fela and inferno-fela, there are no useContext equivalents for the latter yet. We can however leverage the useFela hook to get the
theme
directly.Imports
import { ThemeContext } from 'react-fela'import { ThemeContext } from 'preact-fela'import { ThemeContext } from 'inferno-fela'
Example
import { useContext } from 'react'import { ThemeContext } from 'react-fela'function Button() { const theme = useContext(ThemeContext) // do something with the theme}