use-drunk-state
v0.1.2
Published
Drop in replacement for `setState` that randomizes your stuff every three seconds. Ty <a href="https://github.com/rickhanlonii">@rickhanlonii</a>.
Downloads
4
Readme
use-drunk-state
Drop in replacement for setState
that randomizes your stuff every three seconds. Ty @rickhanlonii.
import { useDrunkState } from 'use-drunk-state';
function App() {
const [thing, setThing] = useDrunkState(null);
const [list, setList] = useDrunkState(['eggs', 'milk', 'test']);
return (
<div>
<h1>Todos</h1>
<ul>
{list.map(item => (
<li key={item}>{item}</li>
))}
</ul>
<input
type="text"
value={thing}
onChange={ev => {
setThing(ev.target.value);
}}
/>
<button
onClick={() => {
setList(list => [...list, thing]);
setThing(null);
}}
>
Add todo
</button>
</div>
);
}