Skip to content

Instantly share code, notes, and snippets.

@lupuszr
Forked from dwhitney/README.md
Last active December 25, 2018 21:21
Show Gist options
  • Save lupuszr/b17c46f5ac446be1ad90b5b1aa8702fb to your computer and use it in GitHub Desktop.
Save lupuszr/b17c46f5ac446be1ad90b5b1aa8702fb 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