0

I have no experience in Frontend development and I am trying to figure out what to try first. In my research I found that there is apparently a difference between React and React Native (cf. What is the difference between React Native and React?). But given that React Native seems to have a superset of the capabilities of React (i.e. also able to create websites with the additional mobile capability), it seems like there is no reason to ever use React. Which is probably false. I mean it is not like React is deprecated or something, right?

So what are the advantages of React over React Native? Is it somehow more efficient for web development? Given that both seem to generate pure html/css/js ("compile") instead of being used directly, this feels like it should be wrong.

Felix B.
  • 905
  • 9
  • 23
  • React Native *uses* React. React Native Web also adds a *huge* number of dependencies making your site significantly heavier. It can be worth it in order to share one codebase, but using React and ReactDOM (which are the bindings to the web DOM) will generally result in a much smaller site size. – jnpdx Jan 19 '22 at 17:33
  • As far as learning the library, it's the same either way. If you learn React, you can use React to either build a website or to build an app with Native. It's not that they're different languages, just a different toolset that uses the same library/syntax. – I wrestled a bear once. Jan 19 '22 at 17:34
  • 4
    Why do we use screwdrivers at all? A hammer is also capable of driving the screw inside a thing. – VLAZ Jan 19 '22 at 17:35
  • @jnpdx so it is more efficient, huh. Why does React Native add those dependencies/why are they not removed during "compile" time? Given that html/js is generated (right?) – Felix B. Jan 19 '22 at 17:53
  • React Native Web (notice the "Web" on the end, which is different than just React Native, which can't be used *alone* to build for the web) adds all of the dependencies because they're necessary to turn all of the RN paradigms into something that works with the DOM. It's essentially like a bunch of poly fills. They don't get removed during compile time because they're a necessary translation layer. For example, on the web, you may use a `div`. On RN, you use a `View`, which is a layer on top of that - that's just the most basic of the examples, though. Lots of complexity with css, etc as well. – jnpdx Jan 19 '22 at 17:55
  • @VLAZ but a screw driven by a hammer won't be as tight as when it is screwed in. Since its threads or its surrounding would be damaged. Most people would know that intuitively. But while a hammer and screw is quite intuitive for most people I do not have intuition about two frameworks I have never used. And I explicitly asked "what are the advantages" guessing that there probably are some – Felix B. Jan 19 '22 at 17:56
  • @jnpdx Why are the RN `View`s not simply replaced by `div`s instead of adding a translation layer? – Felix B. Jan 19 '22 at 17:58
  • Like I said, that's just the most basic of the examples. There's tons of complexity as well, such as converting StyleSheets to CSS, dealing with different forms of input, etc. The bottom line is ReactDOM != RNW. RNW will always be a layer on top – jnpdx Jan 19 '22 at 17:59
  • @jnpdx is that a "in current times" thing? The same could probably at some point be said about C vs ASM "C is always a layer on top" but if the compilers improve this won't be the case anymore. And if React Native is similar to React it seems like it should be more trivial to compile RN to React than it is to compile C to asm. – Felix B. Jan 19 '22 at 18:02
  • RN is not "similar to React" -- it *uses* React. ReactDOM is what interacts with the DOM on the web. It also *uses* React. There is no such things as "compiling RN to React". Yes, maybe some of React Native Web (which again, is *not* the same as React Native) can be optimized away, but it will likely never be as thin as just using React + ReactDOM – jnpdx Jan 19 '22 at 18:06

0 Answers0