So, let’s talk about this for a second. There has been conversation for some time regarding component sharing between React Web and React Native. Is it possible to write a single library of components and share them between both projects?
The web operates in Div’s and Span’s, react native in View’s and Text’s etc.. For those unfamiliar that is the root of the issue.
Link to my working demo repo for react-native-web here, and more at the end.
The first thing I did was to bootstrap from create-react-app. Then you need to
npm install react-native-web, then you are ready to roll.
Now, go ahead and replace your
index.jsfile with the below Gist contents.
You will notice something right away, the attempt of react-native-web is to bring the platform-agnostic functionality of React Native to the web. You are writing React Native code, behind the scenes it gets converted to web friendly components.
To give you an idea, here is my
It looks like there is support for server side rendering, platform specific directives(think make this Button 20em high on web OS and 10 otherwise). It also looks like there is support for testing through Jest.
Here is my github project that you can bootstrap from, just
nmp install and
I am going to dig in more and post a review of features so stay tuned for Part 2. Let me know if your experiences and general thoughts.
Create your free account to unlock your custom reading experience.