npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-fu-hooks

v3.0.0

Published

A collection of useful and reusable custom hooks for React applications.

Downloads

946

Readme

React Usefull Hooks Package

A collection of useful and reusable custom hooks for React applications. These hooks simplify common tasks and enhance your development workflow.

More Hooks are cooming soon be active with react-fu-hooks

Table of Contents

Installation

To install the package, run the following command in your project directory:

npm install react-fu-hooks

Usage

useLocalStorage

Example of useLocalStorage easy way to use in your react component 👍.

import React, { useState } from 'react';
import {useLocalStorage} from 'react-fu-hooks';

const YourComponent = () => {
    const [name, setName] = useLocalStorage('myName', ''); // Initializes
    const [inputValue, setInputValue] = useState('');

    const handleChange = (e) => {
        setInputValue(e.target.value); // Update local state
    };

    const handleSave = () => {
        setName(inputValue); // Save the value to useLocalStorage
    };

    return (
        <div>
            <h1>Your Name:</h1>
            <input
                type="text"
                value={inputValue}
                onChange={handleChange}
                placeholder="Enter your name"
            />
            <button onClick={handleSave}>Save</button>
            <p>Saved Name: {name}</p>
        </div>
    );
};

export default YourComponent;

Explain

const [name, setName] = useLocalStorage('myName', ''); 

In this myName is key for save value and retrieve stored value from useLocalStorage hook second is '' (empty string) as the default and initial value.

This line initializes name by retrieving the value from localStorage using 'name' as the key. If no value is found, it uses '' (empty string) as the default and initial value. The setName function updates both the React state and the localStorage entry for 'name'.

What is useLocalStorage

In this useLocalStorage is a custom hook for saving any type of data in this like useState but one difference. useState is use for store data but when browser are reload(refresh) then reset value from useState but useLocalStorage is save data when reloading(refresh) page so this is best for saving data.

Available Hooks

| Hooks | Type of hook | Description | | :-------- | :------- | :-------------------------------- | | useLocalStorage('key', '') | store values | Required. key important for store value and get. Second parameter is for initial value if you have not initial value you can set '' (empty string) | | useCopyClipboard() | copy values | using this hook you can easily copy any value, links etc. | | useCountDown(11) | count down | Note. In this you can set any number for count down timer |

More Hooks are cooming soon be active with react-fu-hooks

useCopyClipboard

const {copied, copyToClipboard} = useClipboard();


// jsx
<p>copied: {copied && 'Copied Successfully'}</p>
<div className='btn btn-primary' onClick={()=>copyToClipboard('react fu hooks')}>Copy</div>

In this copied is a boolean when user copy anythink then this is true for 2 sec means when copied then you can show a message exmaple Copied Successfully and this message are hide automatically after 2sec.

useCountDown

  const count = useCountDown(11);


// jsx
<p>Timer: {count}</p>

This is for show a count down timer example in this set 11 then start count down from 11 to 0.

Developed By

This package are created by Future Apps Visit Our Website