You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP β†’
Socket
Book a DemoInstallSign in
Socket

sihook

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sihook

Hooks like eating cookies πŸͺ✨

1.0.2
latest
Source
npmnpm
Version published
Weekly downloads
10
25%
Maintainers
1
Weekly downloads
Β 
Created
Source

πŸͺ„ sihook πŸͺ

"Hooks like eating cookies" πŸͺ✨

sihook is a collection of hooks designed to simplify React app development with TypeScript. This package provides a set of useful and ready-to-use hooks to handle common needs in your React applications, making your coding life sweeter! πŸ˜„

πŸš€ Installation

To install sihook, you can use either NPM or Yarn.

Using NPM

npm install sihook

Using Yarn

yarn add sihook

πŸ’‘ Features

  • useLocalStorage: A hook to easily store and retrieve data from localStorage. πŸ—„οΈ
  • useWindowSize: A hook to monitor the window size in real-time. πŸ–₯️
  • useDebounce: A hook to apply debouncing to functions for performance optimization. ⏱️

πŸ› οΈ Usage Examples

useLocalStorage

Store and retrieve values with ease using localStorage! πŸ”

import { useLocalStorage } from 'sihook';

const MyComponent = () => {
  const [value, setValue] = useLocalStorage('myKey', 'defaultValue');

  return (
    <div>
      <p>{value}</p>
      <button onClick={() => setValue('newValue')}>Set Value</button>
    </div>
  );
};

useWindowSize

Keep track of your window size in real-time, and create responsive layouts! πŸ“

import { useWindowSize } from 'sihook';

const MyComponent = () => {
  const { width, height } = useWindowSize();

  return (
    <div>
      <p>Width: {width}</p>
      <p>Height: {height}</p>
    </div>
  );
};

useDebounce

Prevent excessive API calls or re-renders by debouncing your functions! 🐒

import { useDebounce } from 'sihook';

const MyComponent = () => {
  const [search, setSearch] = useState('');
  const debouncedSearch = useDebounce(search, 500);

  return (
    <div>
      <input
        type="text"
        value={search}
        onChange={(e) => setSearch(e.target.value)}
      />
      <p>Debounced Search: {debouncedSearch}</p>
    </div>
  );
};

πŸ“š Documentation

Each hook in sihook comes with clear documentation and usage examples. For more detailed information, check out the repository documentation.

🀝 Contributing

We πŸ’– contributions from the community! If you'd like to contribute, feel free to open an issue or submit a pull request.

πŸ“ License

MIT License. See the LICENSE file for more details.

Keywords

react

FAQs

Package last updated on 23 Feb 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts