build native mobile applications using scala.js and react-native - please check where future work is going to take place :)
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
core/src/main/scala/chandu0101/scalajs/rn react-native 0.8 Jul 26, 2015
doc react-native 0.8 Jul 26, 2015
examples react-native 0.8 Jul 26, 2015
LICENSE Initial commit Apr 1, 2015

Please check (this is where future work is going to take place)


ScalaJS wrapper for react-native .This project depends on scalajs-react , so you must be familiar with scalajs-react in order to use this library.




add this to your sbt build file

libraryDependencies += "com.github.chandu0101.scalajs-react-native" %%% "core" % "0.2.0"


import chandu0101.scalajs.rn._ // to import core builderReactNativeComponentB etc 
import chandu0101.scalajs.rn.components._ // for all native components
import chandu0101.scalajs.rn.apis._ // for native API calls

scalajs-react-native comes with ReactNativeComponentB (its clone of scalajs-react ReactComponentB with native dependencies and extra helper methods ).

Defining Components :

to define components just follow ReactComponentB guide lines

example :

 val HelloNative = ReactNativeComponentB[Unit]("HelloNative")
    .render(P => {
    View(style = styles.container)(
       Text(style = styles.text)("Welcome to Scala-JS ReactNative"),
       Text(style = styles.text)("To get started, edit HelloNative.scala ")

Defining Root Component :

to define root component use buildNative method from builder .

example :

  val ScalaJSReactNative = ReactNativeComponentB[Unit]("ScalaJSReactNative")
      .render((P) => {
    }).buildNative //If your component is going to be render by other third party component then use buildNative

    ReactNative.AppRegistry.registerComponent("ScalaJSReactNative", () => ScalaJSReactNative)


React Native doesn't implement CSS but instead relies on JavaScript to let you style your application. You can define styles in dynamic/typesafe way

Dynamic Way :

Use js.Dynamic.literal to define js styles

Example :

 import scala.scalajs.js.Dynamic.{literal => json}
  val styles = ReactNative.StyleSheet.create(
      container = json(flex = 1,
        backgroundColor = "#F5FCFF"),
      textCenter = json(textAlign = "center",marginTop = 10)
  //access styles 
   View(style = styles.container)(..)
TypeSafe Way :

In order to define styles in type safe manner you need styles module

libraryDependencies += "com.github.chandu0101.scalajs-react-native" %%% "styles" % "0.2.0"

extend trait NativeStyleSheet to define style sheets . NativeStyleSheet comes with two methods style (which takes attr value pairs)and styleE (this is used to extend already defined styles).

Example :

  object styles extends NativeStyleSheet {
    val centering = style(,
    val gray = style(backgroundColor := "#cccccc")
    val horizontal = style(flexDirection.row,
    val default = styleE(centering, gray)(height := 40)


Number of examples can be found in examples module

How to run examples :

 sbt ~fullOptIOS
 // open new terminal tab/window
 cd examples
 npm install
 npm run start // start react-native package
 Open ScalaJSReactNative.xcodeproj using latest xcode
 Cmd+R - to run project
 Cmd+D - to debug project
 Cmd+B - to build
 Cmd+Shift+K - to cleanup


A basic scalajs-react-native skeleton app can be found here