@cheesebit/use-value
v1.0.2
Published
A custom React hook that wraps the existing useState to be used similarly to jQuery's .val().
Downloads
3
Maintainers
Readme
use-value
A custom React hook that wraps the existing useState to be used similarly to jQuery's .val().
Usage
import { useValue } from '@cheesebit/use-value';
function CollapseSample() {
const collapsed = useValue(false)
return (
<div>
{collapsed() ? 'ON' : 'OFF'}
<button
type="button"
onClick={() => {
collapsed(!collapsed())
}}
>
Toggle like this
</button>
<button
type="button"
onClick={() => {
collapsed(isCollapsed => !isCollapsed)
}}
>
Or like this
</button>
</div>
)
}