TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

UseHooks – A Collection of Server Component Safe React Hooks

179 pointsby benadam11almost 2 years ago

12 comments

ecuafloalmost 2 years ago
I think it&#x27;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 think there is more potential in that approach to further React as a whole as the community converges on agreed-upon utilities that become so integral to the way people write and discuss code they make it into the core library.<p>[0] <a href="https:&#x2F;&#x2F;github.com&#x2F;xnimorz&#x2F;use-debounce">https:&#x2F;&#x2F;github.com&#x2F;xnimorz&#x2F;use-debounce</a>
评论 #36130550 未加载
评论 #36133505 未加载
评论 #36130090 未加载
tylermcginnisalmost 2 years ago
Hi everyone!<p>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.<p>Hope you all enjoy!
评论 #36130122 未加载
评论 #36129957 未加载
评论 #36130105 未加载
paulgbalmost 2 years ago
Nicely done!<p>Dumb question, but as someone who is aware of server components but hasn&#x27;t used it, what makes a hook “server component safe”? I assume it doesn&#x27;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?
评论 #36130641 未加载
ricardobeatalmost 2 years ago
How telling is it that a basic core function like useFetch has a warning that it “depends on React’s experimental useEffectEvent”?<p>Almost a decade later and simple data fetching is still an unsolved “problem” in React land.
评论 #36130363 未加载
评论 #36130314 未加载
评论 #36133078 未加载
评论 #36130259 未加载
评论 #36135209 未加载
评论 #36132823 未加载
bottlepalmalmost 2 years ago
How do these compare with the current heavyweight library?<p><a href="https:&#x2F;&#x2F;github.com&#x2F;streamich&#x2F;react-use">https:&#x2F;&#x2F;github.com&#x2F;streamich&#x2F;react-use</a>
评论 #36132164 未加载
nsonhaalmost 2 years ago
I saw `useDebounce` and thought &quot;what the hell does debounce have anything to do with react render cycle?&quot;. When I check the code, `useDebounce` does... I don&#x27;t even know what it does, delayed set state?<p><a href="https:&#x2F;&#x2F;github.com&#x2F;uidotdev&#x2F;usehooks&#x2F;blob&#x2F;380e83fa267157832e9a312b8dd9847e0e6a0f65&#x2F;index.js#L225">https:&#x2F;&#x2F;github.com&#x2F;uidotdev&#x2F;usehooks&#x2F;blob&#x2F;380e83fa267157832e...</a>
评论 #36136474 未加载
stephen123almost 2 years ago
Nice, thank you. It was only the other day I was copy and pasting from the old site. Looking forward to installing the lib and deleting some code.
评论 #36134182 未加载
jackdhalmost 2 years ago
I don&#x27;t know if I&#x27;m being silly, but I&#x27;m trying to find the source behind useLocalStorage<p><a href="https:&#x2F;&#x2F;usehooks.com&#x2F;uselocalstorage" rel="nofollow">https:&#x2F;&#x2F;usehooks.com&#x2F;uselocalstorage</a><p>On their main website Nada, within the github, searching for it only turns up the docs implementation and not the actual source?
评论 #36135579 未加载
评论 #36135551 未加载
1rtyuiopalmost 2 years ago
The landing page has &#x27;useFetch&#x27; in the list but they&#x27;re actually in the experimental branch. I personally think they should be removed from the landing page or somehow marked to let the users know they&#x27;re only available at the experimental release.
sattoshialmost 2 years ago
I don’t understand why this should be distributed as a package of many hooks.<p>Unless if a hook is unusually complicated, I much rather copy-paste it into my code.<p>You should really share the implementations of each of them on the website. I don’t want to pull in 100 hooks just because I don’t want to write 1 from scratch.
评论 #36130820 未加载
评论 #36131030 未加载
评论 #36136956 未加载
barryonionsalmost 2 years ago
Does this work with React-Native? Hard to tell from a quick scan
klysmalmost 2 years ago
I strongly dislike having to think about the color of functions while I’m programming. I want the type system to know
评论 #36135467 未加载