lilactown / helix

A simple, easy to use library for React development in ClojureScript.
Eclipse Public License 2.0
624 stars 52 forks source link

Wrappers for useTransition, useDeferredValue, etc. #128

Open rome-user opened 1 year ago

rome-user commented 1 year ago

Adding the remaining of new React 18 hooks would be nice to have. But some hooks will allow us to provide an API more interesting than simply (def use-x react/useX). For instance, helix.hooks/use-state returns a setter function that can behave like swap!, and helix.hooks/use-ref returns a ref that implements IDeref. Very cool stuff.

In particular, the useTransition hook will benefit from having a similar API to helix.hooks/use-effect, where the body is already wrapped in a fn for us. I plan to sketch some wrappers for this over this weekend.

I am filing this issue so that we can discuss these ideas. In particular, I find useTransition and useDeferredValue to be the most interesting new hooks to target. Both of these hooks give us functionality to run effects or update component state without having to block renders.

lilactown commented 1 year ago

Yeah I think this sounds like a great idea