Skip to content

Instantly share code, notes, and snippets.

@joshburgess
Forked from dwhitney/README.md
Created May 9, 2018 22:35
Show Gist options
  • Save joshburgess/48d4538bb09a7b8a7471b47654e95a95 to your computer and use it in GitHub Desktop.
Save joshburgess/48d4538bb09a7b8a7471b47654e95a95 to your computer and use it in GitHub Desktop.
Quick React Native with PureScript
  1. create-react-native-app purescript-app; cd purescript-app

  2. pulp init --force

  3. pulp build

  4. src/Main.js

var React = require("react");
var RN = require("react-native");

exports.text = function(props){
  return function(str){
    return React.createElement(RN.Text, props, str); 
  };
};
  1. src/Main.purs
module Main where

foreign import data ReactElement :: Type

foreign import text :: forall props. props -> String -> ReactElement

main :: ReactElement
main = text { style : { color : "green", fontSize : 50 } } "Hello from PureScript!" 
  1. ./App.js
import React from 'react';
import Main from "./output/Main";

export default class App extends React.Component {
  render() {
    return Main.main;
  }
}
  1. pulp build

  2. yarn start (create-react-native-app insists you use yarn, but npm may also work)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment