Live data from Hacker News

UseHooks – A Collection of Server Component Safe React Hooks

usehooks.com

11–20 of 62 posts

Re: UseHooks – A Collection of Server Component Safe React Hooks

#11

How telling is it that a basic core function like useFetch has a warning that it “depends on React’s experimental useEffectEvent”? Almost a decade later and simple data fetching is still an unsolved “problem” in React land.

It’s not “unsolved” - it’s just mostly left to the massive number of third-party data-fetching solutions built on top of React.

Re: UseHooks – A Collection of Server Component Safe React Hooks

#12

How telling is it that a basic core function like useFetch has a warning that it “depends on React’s experimental useEffectEvent”? Almost a decade later and simple data fetching is still an unsolved “problem” in React land.

The problem of data fetching is basically the problem of caching, famously one of the two hardest problems in computer science.

Re: UseHooks – A Collection of Server Component Safe React Hooks

#13
post #8

Hi everyone! You old heads may remember the original usehooks. It was built when hooks were first released in 2019. We just rebuilt it from scratch, added about 40 more hooks, made it compliant with Server Components, and launched it as a standalone lib. Hope you all enjoy!

I see "MIT" in package.json - could you add a proper license file to the repo?

Missed that. Thank you. https://github.com/uidotdev/usehooks/blob/main/LICENSE

Re: UseHooks – A Collection of Server Component Safe React Hooks

#14

How telling is it that a basic core function like useFetch has a warning that it “depends on React’s experimental useEffectEvent”? Almost a decade later and simple data fetching is still an unsolved “problem” in React land.

react is a rendering engine, not a framework; there is no opinionated way to fetch data.

react-query is a delightful library that has made data fetching/cacheing a breeze for me - https://tanstack.com/query/v3/docs/react/overview

Re: UseHooks – A Collection of Server Component Safe React Hooks

#15

Hi everyone! You old heads may remember the original usehooks. It was built when hooks were first released in 2019. We just rebuilt it from scratch, added about 40 more hooks, made it compliant with Server Components, and launched it as a standalone lib. Hope you all enjoy!

Was this inspired at all by VueUse? After the windicss/tailwind and Remix/Next.js scuffles it's become clear that it's good to get acknowledgement. Either way, I hope it's as well documented and well maintained as VueUse. That has been pretty sweet. I wanted something like it for React a few months ago and useHooks was the closest thing I found but not nearly as good. Hopefully this relaunch will be.

I've never heard of VueUse (though I'm sure it's great). The original useHooks was released in January of 2019.

Re: UseHooks – A Collection of Server Component Safe React Hooks

#16

Earlier quoted context omitted.

Was this inspired at all by VueUse? After the windicss/tailwind and Remix/Next.js scuffles it's become clear that it's good to get acknowledgement. Either way, I hope it's as well documented and well maintained as VueUse. That has been pretty sweet. I wanted something like it for React a few months ago and useHooks was the closest thing I found but not nearly as good. Hopefully this relaunch will be.

I've never heard of VueUse (though I'm sure it's great). The original useHooks was released in January of 2019.

Yeah, I figured useHooks was created without knowing about VueUse, but thought the useHooks maintainer(s) might have become aware of it sense then. It makes sense, because though the code is heading in the direction of VueUse in terms of being maintained and well rounded, the structure of useHooks is quite a bit different. VueUse has the code alongside the Markdown: https://github.com/vueuse/vueuse/tree/main/packages/integrat...

Re: UseHooks – A Collection of Server Component Safe React Hooks

#17
post #4

I think it's great to have a repo of all the hooks, but I wonder if implementing each from scratch is the right approach. For example, there is an exceptional useDebounce package [0] that handles many more cases than the simplified one on UseHooks, and I think it could be even more useful to highlight exceptional work that has already been done and maintained in the community rather than in-housing everything. I also…

I don’t want to pull in one package for every little piece of functionality. I prefer a package, that includes a bigger set of hooks that I can use. For example like date-fns for date/time.

Re: UseHooks – A Collection of Server Component Safe React Hooks

#18
Nicely done!

Dumb question, but as someone who is aware of server components but hasn't used it, what makes a hook “server component safe”? I assume it doesn't necessarily mean that you can use it on the server (e.g. useMouse), but that if you use it it will not break server-side rendering or complain about a DOM diff?

Re: UseHooks – A Collection of Server Component Safe React Hooks

#19
post #18

Nicely done! Dumb question, but as someone who is aware of server components but hasn't used it, what makes a hook “server component safe”? I assume it doesn't necessarily mean that you can use it on the server (e.g. useMouse), but that if you use it it will not break server-side rendering or complain about a DOM diff?

Not a dumb question. I think calling any hooks server component safe is going to mislead and add confusion to a lot of developers for this very new tech. Hooks are not allowed in server components. This library is SSR safe which has been a concern since before server components were ever a thing.

Re: UseHooks – A Collection of Server Component Safe React Hooks

#20
post #18

Nicely done! Dumb question, but as someone who is aware of server components but hasn't used it, what makes a hook “server component safe”? I assume it doesn't necessarily mean that you can use it on the server (e.g. useMouse), but that if you use it it will not break server-side rendering or complain about a DOM diff?

Not a dumb question. I think calling any hooks server component safe is going to mislead and add confusion to a lot of developers for this very new tech. Hooks are not allowed in server components. This library is SSR safe which has been a concern since before server components were ever a thing.

Yeah it's [poor phrasing](https://twitter.com/tylermcginnis/status/1663648010558132224) on our part. How it's being interpreted vs how I thought it would be interpreted are different. We'll update it.
Post reply on HN