The old way to read context, before useContext existed.

Type Parameters

  • T

See

React Docs

Example

import { UserContext } from './user-context';

function Avatar() {
return (
<UserContext.Consumer>
{user => <img src={user.profileImage} alt={user.name} />}
</UserContext.Consumer>
);
}

Generated using TypeDoc