1.0.0-beta.1 • Published 5 years ago
@sfx-ui/hooks v1.0.0-beta.1
@sfx-ui/hooks
Batch of useful UI-related React hooks.
Installation
npm i @sfx-ui/hooks # react react-domyarn add @sfx-ui/hooks # react react-domMake sure to have
reactandreact-dominstalled in your package as they are included in our peer dependencies.
Usage
Every hook functions is exported by default and should be used inside React components with respect to the rules of hooks.
import useMediaQuery from '@sfx-ui/hooks/use-portal';
/**
* @example
* <PortalComponent>
* <p>Portal content</p>
* </PortalComponent>
*/
const PortalComponent = ({ id, children }) => {
const target = usePortal(id);
return createPortal(
children,
target,
);
};