Created
September 16, 2017 13:40
-
-
Save tiensonqin/56aee51e3deda6d9a84b23f1e73e1f61 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns myapp.core | |
(:require [re-natal.support :as support] | |
[rum.core :as rum :refer-macros [defc defcc]] | |
[cljs-exponent.components :refer [text view image touchable-highlight] :as rn])) | |
(defn ->react | |
"Convert a rum component to a react component." | |
[rum-component] | |
(:rum/class (meta rum-component))) | |
(def ReactNavigation (js/require "react-navigation")) | |
(def StackNavigator (aget ReactNavigation "StackNavigator")) | |
(defc home [] | |
(view {:style {:flexDirection "column" :margin 40 :alignItems "center"}} | |
(text {:style {:fontSize 30 :fontWeight "100" :marginBottom 20 :textAlign "center"}} "Hello World"))) | |
(defn element [element opts & children] | |
(if element | |
(apply (aget cljs-exponent.core/react "createElement") element (clj->js opts) children))) | |
(defn AppRoot [] | |
(-> | |
(StackNavigator (clj->js {:Home {:screen (->react home)}})) | |
(element nil))) | |
(defonce root-component-factory (support/make-root-component-factory)) | |
(defn mount-app [] (support/mount (AppRoot))) | |
(defn init [] | |
(mount-app) | |
(.registerComponent rn/app-registry "main" (fn [] root-component-factory))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment