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.

Twitter.com's HTML, which is produced by React Native for Web, explained

160 pointsby ggurgoneover 3 years ago

21 comments

Milololover 3 years ago
The classic mistake of thinking role=button replaces &lt;button&gt;. It doesn&#x27;t (as mentioned in the linked PR comments). Native HTML buttons are supported by all user agents and assistive technology and provide keyboard and focus requirements by default [1]. The &quot;short answer&quot; they give as to <i>why</i> they did this (a flexbox bug) links to a comment from February saying this was fixed in Firefox 63.<p><a href="https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Web&#x2F;Accessibility&#x2F;ARIA&#x2F;Roles&#x2F;button_role#best_practices" rel="nofollow">https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Web&#x2F;Accessibility&#x2F;A...</a>
评论 #28394489 未加载
评论 #28397037 未加载
评论 #28395534 未加载
rgbrgbover 3 years ago
Lots of classic HN dismissals here, though I am glad we as a community have finally gotten past the anger around requiring JS to use the site.<p>In my mouth, Twitter is probably the best, most responsive web app I&#x27;ve ever used. It is not trivial to make a responsive infinite scroll that remembers your place on back, live updates gracefully, has useful shareable URLs, keeps memory usage low, loads quickly, etc. To me it&#x27;s the real proof point for RN web and web workers.
评论 #28396130 未加载
评论 #28396765 未加载
评论 #28396872 未加载
评论 #28396693 未加载
评论 #28399165 未加载
评论 #28396371 未加载
评论 #28399747 未加载
评论 #28400151 未加载
评论 #28396501 未加载
chadlaviover 3 years ago
&gt; To the eyes of somebody who’s not familiar with the framework, the HTML produced by React Native for Web might look utterly ugly and full of bad practices.<p>To the eyes of someone familiar with the framework it is still full of bad practices.
SergeAxover 3 years ago
Let me write it all down, it&#x27;s a bit confusing. There is a React framework, created to produce Javascript backed applications running in the browser. Then there is a React Native, a wrapper to run those applications on mobile platforms by compiling Javascript apps to native code. And then here is a React Native for Web, a way to compile a Javascript React Native apps into... Javascript to run inside browsers?<p>Boy, that frontend ecosystem is really cursed.
评论 #28404254 未加载
skytreaderover 3 years ago
Amusing anecdote involving div soups: Back in 2010 in one of my CS classes, the professor maintained a Google Sites to communicate with her students and upload slides. At the end of the semester, she wrote a list of students who <i>must</i> take the finals to get at least a passing grade.<p>The thing is, you view it Chrome, the list displays normally, a handful of students. But you view it in Firefox and it&#x27;s an empty list. On Firefox it would look like<p>&gt; (MM&#x2F;DD&#x2F;YY) Here&#x27;s the list of students who must take the finals:<p>&gt;<p>&gt; (MM&#x2F;DD&#x2F;YY) [Next reminder...]<p>Sucks to be a Firefox user and be on that list.<p>A few years later, maybe 2015&#x2F;2016, with a few years in the industry under my belt, I remember this curiosity and rechecked. Firefox is still not showing the list. I open developer tools to inspect and I&#x27;m greeted by an eldritch, decadent, and blasphemous nesting of divs. I did not try to understand it but it seems the stylesheet in use indents divs a certain amount and they abused this rule to get the list to the indentation they want. Probably it hit some limit in Firefox.<p>I&#x27;ve never used Google Sites so I can&#x27;t guess whose fault is this. But it&#x27;s unlikely my prof hand-wrote that HTML.<p>With this article, it seems to me that Twitter devs, for all their fancy dev toolchains, could only produce <i>slightly</i> better HTML than my professor. Perhaps the industry in general is really not much better than Google Sites, seeing our reliance on such bloated frameworks. What a sobering thought.<p>P.S. I did look her up just to check if this bug is still present. Her Google Sites is still up, she still teaches, but she seems to have taken down her earlier course pages.
评论 #28397084 未加载
评论 #28401257 未加载
DoctorOWover 3 years ago
So pardon my ignorance but I thought React was already for web and React Native merely a set of tools to help port React web apps to native mobile apps. What is the difference between React for web and React Native for web?
评论 #28394447 未加载
评论 #28394162 未加载
评论 #28394175 未加载
评论 #28394199 未加载
评论 #28398026 未加载
评论 #28394613 未加载
karimfover 3 years ago
I&#x27;ve been searching a stack which could allow for a single codebase to be rendered in Android, iOS, and the web, and React Native + React Native Web might be the top choice for that. Other competitor includes Flutter, which used to only render canvas on the web, but right now it seems they have an option to render as HTML as well.<p>I bet the need for cross-platform stack might continue to rise in the future. It&#x27;s just impossible for small team&#x2F;solo founder to target 3 different platforms, while handling three different codebases.
评论 #28395023 未加载
评论 #28394372 未加载
评论 #28394242 未加载
评论 #28395018 未加载
评论 #28396208 未加载
评论 #28394366 未加载
评论 #28394452 未加载
评论 #28395400 未加载
评论 #28400378 未加载
评论 #28395823 未加载
notpachetover 3 years ago
I am increasingly of the opinion that we need to ditch HTML in order to protect and advance the open web. We&#x27;ve lost something valuable in this brave new HTML-as-a-compile-target future. The original intention of HTML was to serve as a a lightweight, <i>semantic</i> language that people could use to produce documents that were more-or-less structurally understandable (by both humans and computers). Now it&#x27;s so muddy that we may as well be downloading binary files. (Sometimes we are.)<p>Gone are the days when you could disable custom CSS and still kinda-sorta navigate the web. These days, it is en vogue to tightly couple <i>what</i> we&#x27;re seeing on an HTML page (a product listing, a social media post) with instructions about <i>how</i> to render it (250px wide, black background, blinking marquee text). This is great for the tech companies that are producing these HTML blobs, because they have a lot of control over what they&#x27;re showing to their users. It&#x27;s only good for the users if they&#x27;re 100% happy with how the data is being presented. I don&#x27;t know about you, but I&#x27;m rarely happy these days. To say nothing for users with more stringent accessibility requirements.<p>I wonder if there&#x27;s a future where we all use a different kind of web browser -- one that doesn&#x27;t accept any styling instructions from the websites it&#x27;s visiting. It would probably need to be built on top of accepted data types for various things, like product listings or social media posts. That way, it wouldn&#x27;t matter whether I was looking at a product on Amazon, Ebay or Etsy. I could tell my browser that I want all product listings to be rendered in dark mode, with a thumbnail preview image instead of a full-sized one, regardless of what site I&#x27;m currently on.<p>Google is already in the process of trying to become this kind of &quot;browser&quot;. It has the advantage of being the &quot;front door&quot; of the internet in doing so. It aggregates, and homogenizes, similar documents from various companies and presents them in a uniform way on the results page (eg, hotels, flights, word definitions).<p>I don&#x27;t want to rely on Google to do this for me. I want the documents of the web to be semantically meaningful to the point where my browser can make opinionated decisions about how to style the information I&#x27;m downloading.
评论 #28400162 未加载
bastawhizover 3 years ago
It feels very unnatural to me to use React Native semantics and bolt on props for headings and the like; it seems like it would be better to write &lt;H1&gt; than &lt;Text accessibilityRole=&quot;heading&quot; accessibilityLevel={1}&gt;, even just from a DX perspective.
评论 #28401426 未加载
cruanoover 3 years ago
I love that the site has a screensaver
评论 #28399088 未加载
steviedotbostonover 3 years ago
So this explains how their markup is hot garbage, but not really WHY it is.
评论 #28401267 未加载
评论 #28396219 未加载
cblconfederateover 3 years ago
Too much complexity with garbage excuses. A lot of the web is like that now.<p>You can&#x27;t link to a specific tweet. &#x27;Nuff said
评论 #28394940 未加载
gwbas1cover 3 years ago
???<p>This page is just an animation, and has nothing to do with &quot;Twitter.com&#x27;s HTML, which is produced by React Native for Web, explained&quot;
评论 #28394158 未加载
marstallover 3 years ago
rnweb saved my bacon in an app I did that was architected as a react app hosted within an iOS webview. the killer problem I was facing is that the webview didn&#x27;t handle touches well within a scrolling context. so if you began your scrolling gesture by touching down on a button&#x27;s box, it would often interpret that as a button press.<p>which was hella annoying and a classic &quot;tell&quot; that you are dealing with a web app trying to masquerade as a native app.<p>refactoring to use rnweb&#x27;s &lt;ScrollView&#x2F;&gt; and &lt;Button&#x2F;&gt; made all that go away. Now I&#x27;d (boldly) challenge you to find a &quot;tell&quot; that this app is not native. (shelf.fm if you&#x27;re curious).
antigirlover 3 years ago
Would one have to write custom CSS for the desktop version after the generator has spat out the css? Mobile first, so thats not the issue but targeting the various classes generated would be a pain?
heavyset_goover 3 years ago
Twitter is almost unusable on a machine with 8GB of memory. Many M1 Macs ship with 8GB of memory to this day.
jonplackettover 3 years ago
So why isn&#x27;t React Native for web, just, you know, React? What&#x27;s the difference and why?
评论 #28399528 未加载
chmod775over 3 years ago
I consider any site that loads 3 seconds to display about 100 bytes worth of unicode text to be utter garbage.<p>I actually wanted to check the precise loading times before posting this, but would you look at this: <a href="https:&#x2F;&#x2F;i.imgur.com&#x2F;VWOlNHu.png" rel="nofollow">https:&#x2F;&#x2F;i.imgur.com&#x2F;VWOlNHu.png</a><p>I rest my case.
评论 #28395801 未加载
评论 #28396432 未加载
awinter-pyover 3 years ago
ohhhh finally an explanation for why my whole machine blips when I type into the search box and then I wake up 5 hours later in a stolen car with lost time
xgulfieover 3 years ago
Twitter&#x27;s website is absolute garbage, the feed is unresponsive, tweets fail to load, it&#x27;s just terrible. If you&#x27;re modeling your frontend off of anything please do not pick Twitter because their web experience is awful.
评论 #28395154 未加载
评论 #28395805 未加载
评论 #28395441 未加载
评论 #28396642 未加载
评论 #28397041 未加载
评论 #28395807 未加载
评论 #28395363 未加载
评论 #28396708 未加载
评论 #28396989 未加载
评论 #28394889 未加载
评论 #28396494 未加载
评论 #28395561 未加载
评论 #28396813 未加载
评论 #28397062 未加载
评论 #28396179 未加载
评论 #28396054 未加载
评论 #28395657 未加载
endisneighover 3 years ago
React native I believe is the right approach given the current constraints, but I’d prefer that it would be possible to access native device apis via the browser.<p>Does Twitter really benefit a native app? Perhaps, but it’s certainly not <i>necessary</i>.<p>Ideally iOS and Android would simply expose native apis via browser and allow one to toggle access to said apis per site.<p>My conspiracy theory is that the only reason this isn’t already possible is due to vendors wanting more control.
评论 #28394907 未加载
评论 #28394746 未加载
评论 #28394299 未加载