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>
);
}