Use status is a small substitute for useState that should enable some syntactic sugar.
npm install use-status
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 not?
MIT License © 2024 - Present Fischi20