In a previous post I showed how to use React to create both client side and server side web components. In this post I will demonstrate how to use React Native to create an IOS application.
Obviously web and IOS are completely different runtime environments, but since React acts as a layer of abstraction, it is able to bridge the gap between different technologies. This abstraction is key to cross platform development since it allows us to map React to any supported platform.
Here are the required steps:
Use npm to download the React tools and bootstrap your application by running the below commands:
You will need xcode to test your application in the IOS simulator, but you may use any editor to write React code. The entry point for the React code is a generated file called index.ios.js.
The code below shows index.ios.js and an included greeting component.
This is essentially all you need in order to bootstrap a React Native application.
To test the application in the IOS simulator follow these simple steps:
1) Open a terminal and run the command:
2) Open the generated xcode project (NameOfYourApplication.xcodeproj) and press play.
The application should now launch in xcode and display a greeting.