Get updates via , Github, or RSS | About

Episode 33: React Native with Elm May 5, 2017

Because Elm compiles into Javascript, it’s a candidate to be used with React Native to build native iOS and Android applications. Use ohanhi/elm-native-ui to handle the main application and view layer, and the rest of the Elm architecture to build runtime error-free mobile apps.

Examples

index.ios.js

const { AppRegistry } = require('react-native');
const Elm = require('./elm');
const component = Elm.Main.start();

AppRegistry.registerComponent('CardCounter', () => component);

Main.elm

import NativeUi as Ui exposing (Node)
import NativeUi.Style as Style exposing (defaultTransform)
import NativeUi.Elements as Elements exposing (..)
import NativeUi.Events exposing (..)
import NativeUi.Image as Image exposing (..)

main : Program Never Model Msg
main =
    Ui.program
        { init = ( model, Cmd.none )
        , view = view
        , update = update
        , subscriptions = \_ -> Sub.none
        }