5

Im trying to create an application targettng both web and mobile. The idea is to create react components that differ on how they render but share the logic.

React v.014 blog post stated "we’re splitting the main react package into two: react and react-dom. This paves the way to writing components that can be shared between the web version of React and React Native. The react package contains React.createElement, .createClass, .Component, .PropTypes, .Children, and the other helpers related to elements and component classes. We think of these as the isomorphic or universal helpers that you need to build components."

I've found a great example (http://blog.benoitvallon.com/projects/a-mobile-desktop-and-website-app-with-the-same-code/) that uses the same concept and accomplished the result (react-native 0.13.6 and react 0.14.2).

In this code, you will see nothing special just a smart idea on how to extend react-native naming conventions system to include a web version. The minute I upgrade to latest react-native, it complaints about any component that uses React.Component from the react package instead of react-native.

This is confusing since 0.14 release seem to indicate that was exactly the point moving fw. Let React create components, let react-dom deal with the DOM and let react-native deal with ios/android views.

I think this is a brilliant idea but I cant seem to pass this particular problem. Any thoughts, ideas will be greatly appreciated.

Thanks

sesteva
  • 1,716
  • 2
  • 16
  • 17

1 Answers1

0

The transition to make react native work this way is underway but incomplete. See AMA.

We are working hard to stop using our fork such that people can use require('react') and work the same as require('react-native'), this will make it possible for all the third party plugins to work on both places without doing anything.

Right now we can't use relay on the open source version of react-native without forking it, which is a huge shame and we're working on fixing that.

Community
  • 1
  • 1
Harry Moreno
  • 10,231
  • 7
  • 64
  • 116