react.js breakpoint hook provided with context
a react.js hook for breakpoint that's provided with context for efficient checking
get it from yarn/npm whatever
``
yarn add @abdulghani/breakpointcontext
npm install @abdulghani/breakpointcontext
`
use it as simple as
`typescript
import BreakpointContext, { useBreakpoint } from "@abdulghani/breakpointcontext";
const MyComponent = () => {
return (
)
}
// and use it in your component
const YourSuperAwesomeChildren = () => {
const breakpoint = useBreakpoint();
if (breakpoint === "sm")
return
you can put your own config to define your own set of breakpoints
`typescriptconst MyComponent = () => {
return (
)
}
`the option is typed as such
`typescript
type breakpoints = {
[keys: string]: number; // set of breakpoint value tied to the key as the label
};
``