Skip to content

This is the useful custom hooks for the React Js and WordPress Gutenberg

Notifications You must be signed in to change notification settings

vanpariyar/npm-package-custom-hooks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

My Personalized Custom Hooks that i am using for React and Gutenberg Wordpress Editor.

Purpose for using this

  • No need to understand Comeplex redux for the small piece of the task.
  • easily share the component data with diffrent components
  • Work Like same as useState

Package Link

use

import { useLocalStorage, useSessionStorage } from '@vanpariyar/hooks'
import { useEffect } from 'react'


const functionalComponent = () => {
    const[ newsArticles, setNewsArticles ] = useSessionStorage( 'newsArticles', InitialValue );

    // OR

    const[ newsArticles, setNewsArticles ] = useLocalStorage( 'newsArticles', InitialValue );

    useEffect(()=>{
        if( newsArticles ) { return };
        setArticles( [ 1, 2, 3 ] )
    },[])
    
}

export default functionalComponent;

than in any compnent

import { useLocalStorage, useSessionStorage } from '@vanpariyar/hooks'

const otherFunctionalComponent = () => {
    const[ newsArticles, setNewsArticles ] = useSessionStorage( 'newsArticles', InitialValue );

    // OR

    const[ newsArticles, setNewsArticles ] = useLocalStorage( 'newsArticles', InitialValue );

    console.log( newsArticles );
}

export default otherFunctionalComponent;

Credits

webdev simplified: The useLocalStorage hook is inspired by them Thank you.

About

This is the useful custom hooks for the React Js and WordPress Gutenberg

Resources

Stars

Watchers

Forks

Packages

No packages published