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.

Designing simpler React components

54 pointsby cjrabout 9 years ago

7 comments

ameliusabout 9 years ago
Immutable data-structures are useful, but also it is quite a lot of work to transform a codebase written with mutable data-structures into one with immutable ones. This is because mutability is a "viral" property.
评论 #11368309 未加载
评论 #11373245 未加载
tracker1about 9 years ago
I&#x27;d go a step further than mentioned... as static render components (single functions) are possible... if you&#x27;re using something like redux&#x2F;connect, you can export the static function, along with the default of the connected version. By doing this you have really straight forward testing, and don&#x27;t even have to deal with the variance of class&#x2F;object instances. I&#x27;ve build a few apps at this point using only static components.<p>Also, there are options to use immutable for state with redux (it&#x27;s a little different), but it can be useful, to say the least.<p>The only downside of static components is that hot module replacement doesn&#x27;t seem to work right, there are ways around it, but not as much fun... that said, I tend to save state to sessionStorage on every change, loading from sessionStorage at start, so refreshing the browser will just show the updated rendering.
CGamesPlayabout 9 years ago
How does all of the cloning affect performance? It feels wasteful to create these short-lived components that are explicitly discarded for slightly modified ones, but is that actually a problem?
评论 #11368581 未加载
评论 #11374077 未加载
z1mm32m4nabout 9 years ago
Interesting, the examples don&#x27;t use JSX syntax. I wonder, does this make it easier to work with TypeScript, or do they have some other reasoning for not using JSX?
iandanforthabout 9 years ago
Any numbers for &quot;enormous performance boost&quot; when over-riding componentShouldUpdate?
评论 #11367811 未加载
gamefaceabout 9 years ago
I&#x27;m new to all this, but it seems like redux addresses a lot of these concerns, no?
评论 #11367917 未加载
评论 #11368278 未加载
评论 #11368517 未加载
pspeter3about 9 years ago
Previous link: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=11338109" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=11338109</a>