Superhooks is a simple, modern, server-safe React Hooks.
Compatible with React v16.8.0+.
npm install superhooksyarn add superhookspnpm install superhooksThis project uses jest as the testing framework and React Testing Library (RTL) for testing React components and hooks.
To execute all unit tests with coverage enabled
npm run testimport { useWindowSize } from '../hooks/useWindowSize';
function ExampleComponent() {
const { width, height } = useWindowSize();
return (
<div>
<p>Window width: {width}px</p>
<p>Window height: {height}px</p>
</div>
);
}
export default ExampleComponent;Superhooks is always open to improvements and contributions, you can check the Open Issues if you want to contribute, and it's also possible to request to add your own improvements/ideas using the Feature Request template. Before contributing, please read the Contribution Guide and make sure to respect the standards!
useWindowSize()- Tracks and updates browser window size on resize.useDebounce()- Delays updating the value until after the specified delay.useLocalStorage()- Persist a state value in localStorage.
MIT
