Skip to content

hermanwikner/use-param-state

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

useParamState

React hook that works much like useState, but it encodes the state and saves it in a parameter in the URL.

Installation

yarn add use-param-state or npm i use-param-state

Usage

The hook accepts an object as a prop with the following properties:

  • initialState?: <T> – The initial state
  • key: string – The URL parameter key for the encoded state
import {useParamState} from 'use-param-state'

const [state, setState] = useParamState<string>({
  initialState: 'Hello world',
  key: 'myKey',
})

About

React hook that works much like useState, but it encodes the state and saves it in a parameter in the URL

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published