@atlaskit/avatar
Version:
An avatar is a visual representation of a user or entity.
13 lines (12 loc) • 476 B
JavaScript
import { createContext, useContext } from 'react';
/**
* Used to ensure Avatar sub-components are used within a Avatar component,
* and provide a useful error message if not.
*/
export const EnsureIsInsideAvatarContext = /*#__PURE__*/createContext(false);
export const useEnsureIsInsideAvatar = () => {
const context = useContext(EnsureIsInsideAvatarContext);
if (!context) {
throw new Error('Avatar sub-components must be used within a Avatar component.');
}
};