react-native/blog/2017-03-13-introducing-crea...

2.9 KiB
Raw Blame History

title author authorTitle authorURL authorImage authorTwitter category
Introducing Create React Native App Adam Perry Software Engineer at Expo https://github.com/dikaiosune https://avatars2.githubusercontent.com/u/6812281 dika10sune engineering

Today were announcing Create React Native App: a new tool that makes it significantly easier to get started with a React Native project! Its heavily inspired by the design of Create React App and is the product of a collaboration between Facebook and Expo (formerly Exponent).

Many developers struggle with installing and configuring React Natives current native build dependencies, especially for Android. With Create React Native App, theres no need to use Xcode or Android Studio, and you can develop for your iOS device using Linux or Windows. This is accomplished using the Expo app, which loads and runs CRNA projects written in pure JavaScript without compiling any native code.

Try creating a new project (replace with suitable yarn commands if you have it installed):

$ npm i -g create-react-native-app
$ create-react-native-app my-project
$ cd my-project
$ npm start

This will start the React Native packager and print a QR code. Open it in the Expo app to load your JavaScript. Calls to console.log are forwarded to your terminal. You can make use of any standard React Native APIs as well as the Expo SDK.

What about native code?

Many React Native projects have Java or Objective-C/Swift dependencies that need to be compiled. The Expo app does include APIs for camera, video, contacts, and more, and bundles popular libraries like Airbnbs react-native-maps, or Facebook authentication. However if you need a native code dependency that Expo doesnt bundle then youll probably need to have your own build configuration for it. Just like Create React App, “ejecting” is supported by CRNA.

You can run npm run eject to get a project very similar to what react-native init would generate. At that point youll need Xcode and/or Android Studio just as you would if you started with react-native init , adding libraries with react-native link will work, and youll have full control over the native code compilation process.

Questions? Feedback?

Create React Native App is now stable enough for general use, which means were very eager to hear about your experience using it! You can find me on Twitter or open an issue on the GitHub repository. Pull requests are very welcome!