export function useContext<T>(context: React.Context<T>): () => T
Accepts a context object.
Subscribes to context changes and returns contextGetter.
contextGetter
import { afc, useContext } from 'react-afc' import { NameContext } from './NameContext' function Component(props) { const getContext = useContext(NameContext) function greet() { const name = getContext() return `Hi, ${name}!` } return () => ( <p>{greet()}</p> ) } export default afc(Component)
There was an error while loading. Please reload this page.
Component
Lifecycle
State
Redux
Other