Live data from Hacker News

UseHooks – A Collection of Server Component Safe React Hooks

usehooks.com

41–50 of 62 posts

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

#41
post #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.

I agree with you. We will actually start playing around with use hooks. One package that has multiple utilities maintained by one entity is great. When you have multiple dependencies from multiple entities in your code, the surface area for supply chain attack is larger.

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

#42

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.

How does this suggest, in any way, that fetching is an “unsolved problem” in “React land”?

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

#43

Earlier quoted context omitted.

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.

I don't blame you for this. The React team recently talking about "React Server Components" as though most React users are running it on NodeJS backends and introducing magic "use client" strings is putting everyone in a confused position and I don't think there's a good phrasing for you.

Something like "compatible for server-side rendering in non react server components" :)

And people suggest juniors to start on the front-end because it's less complicated...

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

#46
post #3

Earlier quoted context omitted.

Are all the hooks on the site made by ui.dev? It'd be great if each hook linked to the Github code for that hook, as the first thing I thought of was (a) what is the hook doing, and (b) is it easier to adapt my existing hook and reduce the number of dependencies I have to track?

Good feedback. Yes they're all up on Github – https://github.com/uidotdev/usehooks

Left another main comment, however you may not see it, where is useLocalStorage implementation for example?

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

#47
post #45

I don't know if I'm being silly, but I'm trying to find the source behind useLocalStorage https://usehooks.com/uselocalstorage On their main website Nada, within the github, searching for it only turns up the docs implementation and not the actual source?

looks like it's in the experimental branch https://github.com/uidotdev/usehooks/blob/experimental/index...

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

#48
post #45

I don't know if I'm being silly, but I'm trying to find the source behind useLocalStorage https://usehooks.com/uselocalstorage On their main website Nada, within the github, searching for it only turns up the docs implementation and not the actual source?

It’s in the experimental branch - https://github.com/uidotdev/usehooks/blob/d7483140ee803826c3...

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

#49
I saw `useDebounce` and thought "what the hell does debounce have anything to do with react render cycle?". When I check the code, `useDebounce` does... I don't even know what it does, delayed set state?

https://github.com/uidotdev/usehooks/blob/380e83fa267157832e...

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

#50

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

That ceased to be true long ago. How do you use native fetch() with a functional component achieving correct/expected behaviour? It’s not possible without buying into react’s [very opinionated] hooks.

In fact, the toolbox this whole HN entry is about is a great example of how React is not just a rendering engine. It wouldn’t even be necessary otherwise. Peek at the code and what you’ll see is intense use of a DSL and built-in methods provided by React, to wrap native APIs that are otherwise usable without any wrappers.

I’m also a happy user of react-query, but it uses the same underlying hooks which are a moving target.

Post reply on HN