Skip to content

Small useState alternative, no specific reason why

License

Notifications You must be signed in to change notification settings

fischi20/use-status

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

use-status

npm version

Use status is a small substitute for useState that should enable some syntactic sugar.

installation

npm install use-status

example usage

import {useStatus} from 'react-use-status'
//or
import useStatus from 'react-use-status'

const count = useStatus(0)
return <>
  <button onClick={() => count(oldValue => oldValue+1)}>+</button>
  <button onClick={() => count.value--} >-</button>

  {/* The next 2 lines are equivalent to get the value of the state*/}
  <p>{count.value}</p>
  <p>{count()}</p>
</>

Why?

Why not?

MIT License © 2024 - Present Fischi20

About

Small useState alternative, no specific reason why

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published