News for hackers. Stuff that matters.
Re:React I love you, but you're bringing me down by mmis1000 on Tuesday September 20, 2022 @02:09PM (#32915612)
I used it in a few project. And it reduces the code by a lot.

For example. To make a mutex to prevent duplicate submit of form. You use need to declare a instance field and wraps the code that do the submit. That alone is 3 lines of code but don't even include error handling.

But now I sealed it into a one line hook

    const wrap = useMutex()
    const submit = wrap(async () = { … })
And then the submit can't run in parallel now.

There are no comments on this comment yet.