Live data from Hacker News

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

giuseppegurgone.com

31–40 of 163 posts

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

#32

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. Does Twitter really benefit a native app? Perhaps, but it’s certainly not necessary . Ideally iOS and Android would simply expose native apis via browser and allow one to toggle access to said apis per site. My conspiracy theory is that the only reason this…

With React Native Web, that's exactly what this gives you. Basically you get a PWA for free with your app. All "native" features that you have can then use web device apis if they exist. Basically React Native Web allows you to have a lite version of your app that lives on the web.

Yes, but then you must use React Native. What I’m describing is that you could use regular JavaScript to access native apis.

That way if you preferred Vue, Angular, Ember, Elm, etc you could use that.

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

#33
post #26
post #3

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?

React and React Native are separate tools, and they don't play with each other. You actually need to build two separate apps and you don't get much of any re-use. For example, you can't use Material UI for React in React Native, and you can't build a React component library and just pull it into React Native. So if you want a fully cross platform React experience, you need React Native from the get-go and to compile…

Almost holding my breath for the time we see a version of react native for web getting packaged into a container that mimicks a native mobile app. And back then I thought that I've seen it all when apps built with scalajs-react-native appeared on Android.

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

#34
post #26
post #3

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?

React and React Native are separate tools, and they don't play with each other. You actually need to build two separate apps and you don't get much of any re-use. For example, you can't use Material UI for React in React Native, and you can't build a React component library and just pull it into React Native. So if you want a fully cross platform React experience, you need React Native from the get-go and to compile…

This isn't really accurate. Presuming you're using react-native-web [1] (the most popular version of RN targeting the web, although there are others), it's essentially just a set of components and APIs, fulfilling RN's API, which sit on top of React DOM.

So anything you could do in React, you can also do in RNWeb, as it's a superset of React.

Of course, you'd need to use the RN components if you want to share code between web and native mobile. But there's nothing stopping you reaching a high degree of code re-use, and/or using React components for the web-only portion of a RNWeb project.

[1] https://github.com/necolas/react-native-web

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

#35
post #14

Earlier quoted context omitted.

Cross-platform frameworks work great for basic CRUD apps but when you start to do things more complicated it can be a headache. Sometimes hardware and features you want to leverage are specific to the platform.

With React Native you can just use file.ios.js or file.windows.js etc if you want to do something different entirely for a platform. You can also check the platform with a function for minor adjustments. You can also handle these differences in a RN extension if they involve native code. You can model your codebase so the function stubs are the same, but the implementation differs based on platform. So you can use it…

> With React Native you can just use file.ios.js or file.windows.js etc if you want to do something different entirely for a platform. You can also check the platform with a function for minor adjustments. You can also handle these differences in a RN extension if they involve native code.

Well if you need a specific widget or library that react native doesn't support by default you have to write bindings, and unless your business logic is very basic it happens most of the time. You might be lucky somebody already did write some bindings for you. As someone that used Titanium in the past, React Native suffers from the exact same problems.

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

#36
post #31

Twitter's website is absolute garbage, the feed is unresponsive, tweets fail to load, it's just terrible. If you're modeling your frontend off of anything please do not pick Twitter because their web experience is awful.

Is there any infinite scrolling website that works smoothly on mobile devices?

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

#38

Earlier quoted context omitted.

With React Native Web, that's exactly what this gives you. Basically you get a PWA for free with your app. All "native" features that you have can then use web device apis if they exist. Basically React Native Web allows you to have a lite version of your app that lives on the web.

Yes, but then you must use React Native. What I’m describing is that you could use regular JavaScript to access native apis. That way if you preferred Vue, Angular, Ember, Elm, etc you could use that.

Well you can, but the point of React is to abstract the view from the platform, not much more.

You can use something like Solid or JSX lite to maintain standard components that are compatible with most of those frameworks and web components.

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

#39

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. Does Twitter really benefit a native app? Perhaps, but it’s certainly not necessary . Ideally iOS and Android would simply expose native apis via browser and allow one to toggle access to said apis per site. My conspiracy theory is that the only reason this…

> Ideally iOS and Android would simply expose native apis via browser and allow one to toggle access to said apis per site.

Not when the different stores are so lucrative. Imagine that initially Jobs wanted people to stick to web apps and reserve native apps for Apple teams. fast foward 13 years, Apple made billions with their appstore.

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

#40

Earlier quoted context omitted.

Yes, but then you must use React Native. What I’m describing is that you could use regular JavaScript to access native apis. That way if you preferred Vue, Angular, Ember, Elm, etc you could use that.

Well you can, but the point of React is to abstract the view from the platform, not much more. You can use something like Solid or JSX lite to maintain standard components that are compatible with most of those frameworks and web components.

Whether the view is abstracted from the platform and whether you have native access to apis are separate issues.

Even if you use web components that doesn’t change the fact that web apps don’t have access to native apis without compilation.

Post reply on HN