ReactJS to React Native

David Yu
Shanghai Coders
Published in
2 min readMay 19, 2018
Photo by Moritz Kindler on Unsplash

After two years doing web stuff in ReactJS, I have been itching to do a production-ready React Native App.

Finally, a client asked, “You did React before, right?”

Me: “Yea”

Client: “Then React native shouldn’t be a problem?”

Me: “Yea, it should be quite similar”

Haha, I was so naive…

Here is a list of things that I wish I knew going from ReactJS to React Native

Although it’s JSX syntax, you’re not in the web development world anymore

The styleSheet is similar, but not the same as CSS. There are no global styles if it’s not imported.

Even if I want to do something like ```Text { color: white; }```, I can’t…yet. (wink. wink. Facebook developers)

Remember to connect your device and your laptop to the same wifi if you’re using a remote debugger.

“Responsive” Design take a lot more effort than defining media query

  • Think about a big phone, a little phone, a portrait, and a landscape view.
  • Elie has a great implementation.
  • Or if you want a library solution.

The third-party module can only take you so far

Move on to the next third-party modules if one is not working, because react-native changes fast. Some third-party modules are just outdated.

Some companies only provide SDK in Object-C or Swift. Hope there’s a nice person who would write a wrapper for you, or have fun learning another language.

Learn to bridge native module

Live reload/Hot reload won’t save time from compiling native code

Remove unused modules when experimenting fails, or your life will be spent waiting for Xcode to compile

Be prepared for Build Failed, so before you link some new library commit your previous changes

  • rm -rf node_module && yarn i && cmd + K to clean build-cache solves 80% of the problem

Native-like performance is not exactly native

  • setInterval lose accuracy when it’s under 1 second, see it in action
  • An excellent comparison between native iOS and react native, here.

Overall, React native is an awesome framework. It has granted me the ability to build a mobile app quickly. Or else, I would still be learning Objective-C or Swift and starting from the basics. If you are a web developer thinking about moving into the mobile app world, I would say pick an idea and just do it. Please free to reach out to the online communities, or you can message me on LinkedIn.

For more information, please visit shanghaicoders.com

--

--

David Yu
Shanghai Coders

Full-stack developer based in Shanghai. I help people turning their ideas into reality.