TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: p(react): Classical .vs Functional? or wrong question?

1 点作者 clumsycomputer大约 2 年前
i gotta say i&#x27;ve got implementing react-style functional components down to a science with a sprinkle of art and am just so pleased with how formulaic it feels when going about building :) with that said there is still room for improvement and wouldn&#x27;t mine having some conversation around different paths forward<p>i gotta say that i&#x27;ve got implementing react-style functional components down to a science with sprinkles of art and am just so pleased with how formulaic it feels when going about building :) with that said there is still room for improvement and would love to have some conversation about different paths forward<p>in short, the style i&#x27;ve honed is linear, verbose, and makes a serious effort to avoid unnecessary indirection. that means i use inline functions a lot for things like event handlers. in a medium to large application this becomes a performance problem and i want to be a professional when it comes to this sort of thing. thus it is time to reevaluate my approach to this whole component design &#x2F; implementation thing<p>in general, im trying to strip magic (abstraction) from my life rather than welcoming more of it in! so rather than climbing further up that ladder of magic and bathing in signals, which preact offers, i think i’ll be better off climbing back down to class(ical) components where i began my declarative component journey at the start of 2016<p>START UNNECESSARY DETOUR at this point you might wonder if i flagellate myself? the answer to that… “¡¡¡depends who you ask!!!” END UNNECESSARY DETOUR<p>when i got started with class ccomponents not much made sense. there was just so much noise resulting from my lack of experience that making head from tails when trying to diagnose the smallest of problems felt like an expedition. fast forward to present and uncountable iterations later, class components now have a shine to them! less runtime waste, but at the cost of mas indirection. also with classes i should be able to implement more robust types within typescript!<p>am i just looking for a problem, or do class components offer the best path forward for performance optimizations? why not signals? ps i’ve done the signal thing with vue and though it has its appeals it seems like there aren’t any good escape hatches for performance hacking<p>so how are y&#x27;all going about p(react)-style component design &#x2F; implementation? what in your approach are you proud of? what about your approach is worrying?<p>any of you implementing new components with classes? or are class components only a legacy thing? if implementing new, what is your approach?

暂无评论

暂无评论