-
-
Save iamjarvo/a69f1bf39d1adac6dda4 to your computer and use it in GitHub Desktop.
This file contains 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
## core.cljs | |
;; Need to set js/React first so that Om can load | |
(set! js/React (js/require "react-native/Libraries/react-native/react-native.js")) | |
(ns test.core | |
(:require [om.core :as om])) | |
;; Reset js/React back as the form above loads in an different React | |
(set! js/React (js/require "react-native/Libraries/react-native/react-native.js")) | |
;; Setup some methods to help create React Native elements | |
(defn view [opts & children] | |
(apply js/React.createElement js/React.View (clj->js opts) children)) | |
(defn text [opts & children] | |
(apply js/React.createElement js/React.Text (clj->js opts) children)) | |
(defn navigator-ios [opts] | |
(js/React.createElement js/React.NavigatorIOS (clj->js opts))) | |
;; Set up our Om UI | |
(defonce app-state (atom {:text "Welcome to react native"})) | |
(defn search [owner] | |
(reify | |
om/IRender | |
(render [this] | |
(view {:style {:flexDirection "column" :margin 40}} | |
(text nil "react native"))))) | |
(defn widget [data owner] | |
(reify | |
om/IRender | |
(render [this] | |
(navigator-ios {:style {:flex 1} | |
:initialRoute {:component (om/build search owner) :title "Search"}})))) | |
(om/root widget app-state {:target 1}) | |
(defn ^:export init [] | |
((fn render [] | |
(.requestAnimationFrame js/window render)))) | |
## error | |
;; Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not find the app init function' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment