2 ms·
Not out of a box. There's not a huge difference in environments but automatic porting was never a design goal. React Native follows the mantra "learn once, writ
by underwater 12y ago
Not out of a box. There's not a huge difference in environments but automatic porting was never a design goal. React Native follows the mantra "learn once, write anywhere" instead of "write once run anywhere". The main differences are:
* React Native has its own primitive components (Text or View) instead of primitives that map to standard HTML elements (span, div).
* React Native's runtime environment won't have all the browser APIs (DOM, navigation, web storage).
* React Native uses a subset of CSS and exposes it through the JS API instead of relying on the browser's styling (and separate CSS files).
That said, porting components is trivial. If you have a library of core components (Buttons, Menus, TabBars, etc.) then porting just those to the native implementation gets you most of the way there.
It's also possible to alias Text => span, View => div, etc. and use React Native's css-layout library on the web. But that won't help for legacy applications.
- pests 12y agoWhile I've had no problems with React's coupling of components controller and view in one location, doesn't this suggest that it should be separated? One view for web, one for RN using the same state and controller?
- underwater 12y agoThat's how we've approached the apps I've been involved in. Your Flux or Relay stores and non component modules can be shared. This isn't a hard and fast rule, just an acknowledgment that different platforms have different constraints and conventions. If you try and share all your code then you'll end up designing for the lowest common denominator, and your app will feel out of place.