n1ru4l / react-use-transition

14 stars 2 forks source link

improve readme #5

Open n1ru4l opened 3 years ago

n1ru4l commented 3 years ago
talentlessguy commented 3 years ago

I would also recommend to rename the proj not to be unscoped, for example to use-stable-transition

sibelius commented 3 years ago

What about following more closely the React useTransition (https://github.com/facebook/react/blob/6d3ecb70dceb225af0cd990b46d6c44b852c1d82/packages/react/src/ReactHooks.js#L148)

const [startTransaction, isPending] = useTransition()

but also returning the cachedProps for now?

n1ru4l commented 3 years ago

startTransition is not really needed as the transition is started by the consumed data fetching hook triggering a re-render and returning a new loading state and data. But I agree that we could flip the stuff into:

const [cachedProps, isPending] = useTransition(data, isLoading)

I definitely wanna keep the @n1ru4l prefix, that is the least amount of effort I can make to remind people they use stuff that another person wrote :)

I also wanna keep the react- prefix, so people immediately know that this is something react-related.

@n1ru4l/react-use-stable-transition

@n1ru4l/react-use-loading-transition

@n1ru4l/react-use-state-transition

TBH when you search for the transition you find only CSS created stuff so maybe the naming does not feel that natural to me. Historically, I first named this hook useCurrent when I wrote https://dev.to/n1ru4l/homebrew-react-hooks-usecurrent-47o5