Neverending Plethora of Modules

    use-drunk-state

    0.1.2 • Public • Published

    use-drunk-state

    Drop in replacement for setState that randomizes your stuff every three seconds. Ty @rickhanlonii.

    Screenshot 2019-04-27 at 3 40 02 pm
    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>
        );
    }

    Keywords

    none

    Install

    npm i use-drunk-state

    DownloadsWeekly Downloads

    9

    Version

    0.1.2

    License

    none

    Unpacked Size

    19 kB

    Total Files

    13

    Last publish

    Collaborators

    • walaura