make om-next and rum templates work nicely with RN 0.25+

- fix usage of React and ReactNative API by removing natal-shell dependency
This commit is contained in:
Artur Girenko 2016-05-13 23:57:39 +02:00
parent a721661ad0
commit 3cb3af47e3
4 changed files with 32 additions and 14 deletions

View File

@ -66,8 +66,7 @@ interfaceConf =
android: ["core.cljs"] android: ["core.cljs"]
common: ["state.cljs"] common: ["state.cljs"]
other: [["support.cljs","re_natal/support.cljs"]] other: [["support.cljs","re_natal/support.cljs"]]
deps: ['[org.omcljs/om "1.0.0-alpha28" :exclusions [cljsjs/react cljsjs/react-dom]]' deps: ['[org.omcljs/om "1.0.0-alpha28" :exclusions [cljsjs/react cljsjs/react-dom]]']
'[natal-shell "0.1.6"]']
shims: ["cljsjs.react", "cljsjs.react.dom"] shims: ["cljsjs.react", "cljsjs.react.dom"]
sampleCommandNs: '(in-ns \'$PROJECT_NAME_HYPHENATED$.state)' sampleCommandNs: '(in-ns \'$PROJECT_NAME_HYPHENATED$.state)'
sampleCommand: '(swap! app-state assoc :app/msg "Hello Native World!")' sampleCommand: '(swap! app-state assoc :app/msg "Hello Native World!")'
@ -78,8 +77,7 @@ interfaceConf =
android: ["core.cljs"] android: ["core.cljs"]
common: [] common: []
other: [["sablono_compiler.clj","sablono/compiler.clj"],["support.cljs","re_natal/support.cljs"]] other: [["sablono_compiler.clj","sablono/compiler.clj"],["support.cljs","re_natal/support.cljs"]]
deps: ['[rum "0.8.3" :exclusions [cljsjs/react cljsjs/react-dom sablono]]' deps: ['[rum "0.8.3" :exclusions [cljsjs/react cljsjs/react-dom sablono]]']
'[natal-shell "0.1.6"]']
shims: ["cljsjs.react", "cljsjs.react.dom", "sablono.core"] shims: ["cljsjs.react", "cljsjs.react.dom", "sablono.core"]
sampleCommandNs: '(in-ns \'$PROJECT_NAME_HYPHENATED$.ios.core)' sampleCommandNs: '(in-ns \'$PROJECT_NAME_HYPHENATED$.ios.core)'
sampleCommand: '(swap! app-state assoc :greeting "Hello Clojure in iOS and Android with Rum!")' sampleCommand: '(swap! app-state assoc :greeting "Hello Clojure in iOS and Android with Rum!")'

View File

@ -1,15 +1,25 @@
(ns $PROJECT_NAME_HYPHENATED$.$PLATFORM$.core (ns $PROJECT_NAME_HYPHENATED$.$PLATFORM$.core
(:require-macros [natal-shell.components :refer [view text image touchable-highlight]]
[natal-shell.alert :refer [alert]])
(:require [om.next :as om :refer-macros [defui]] (:require [om.next :as om :refer-macros [defui]]
[re-natal.support :as sup] [re-natal.support :as sup]
[$PROJECT_NAME_HYPHENATED$.state :as state])) [$PROJECT_NAME_HYPHENATED$.state :as state]))
(set! js/window.React (js/require "react-native")) (set! js/window.React (js/require "react"))
(def ReactNative (js/require "react-native"))
(defn create-element [rn-comp opts & children]
(apply js/React.createElement rn-comp (clj->js opts) children))
(def app-registry (.-AppRegistry ReactNative))
(def view (partial create-element (.-View ReactNative)))
(def text (partial create-element (.-Text ReactNative)))
(def image (partial create-element (.-Image ReactNative)))
(def touchable-highlight (partial create-element (.-TouchableHighlight ReactNative)))
(def app-registry (.-AppRegistry js/React))
(def logo-img (js/require "./images/cljs.png")) (def logo-img (js/require "./images/cljs.png"))
(defn alert [title]
(.alert (.-Alert ReactNative) title))
(defui AppRoot (defui AppRoot
static om/IQuery static om/IQuery
(query [this] (query [this]

View File

@ -1,15 +1,25 @@
(ns $PROJECT_NAME_HYPHENATED$.$PLATFORM$.core (ns $PROJECT_NAME_HYPHENATED$.$PLATFORM$.core
(:require-macros [natal-shell.components :refer [view text image touchable-highlight]] (:require-macros [rum.core :refer [defc]])
[natal-shell.alert :refer [alert]]
[rum.core :refer [defc]])
(:require [re-natal.support :as support] (:require [re-natal.support :as support]
[rum.core :as rum])) [rum.core :as rum]))
(set! js/window.React (js/require "react-native")) (set! js/window.React (js/require "react"))
(def ReactNative (js/require "react-native"))
(defn create-element [rn-comp opts & children]
(apply js/React.createElement rn-comp (clj->js opts) children))
(def app-registry (.-AppRegistry ReactNative))
(def view (partial create-element (.-View ReactNative)))
(def text (partial create-element (.-Text ReactNative)))
(def image (partial create-element (.-Image ReactNative)))
(def touchable-highlight (partial create-element (.-TouchableHighlight ReactNative)))
(def app-registry (.-AppRegistry js/React))
(def logo-img (js/require "./images/cljs.png")) (def logo-img (js/require "./images/cljs.png"))
(defn alert [title]
(.alert (.-Alert ReactNative) title))
(defonce app-state (atom {:greeting "Hello Clojure in iOS and Android!"})) (defonce app-state (atom {:greeting "Hello Clojure in iOS and Android!"}))
(defc AppRoot < rum/cursored-watch [state] (defc AppRoot < rum/cursored-watch [state]

View File

@ -1,7 +1,7 @@
(ns re-natal.support (ns re-natal.support
"Helpers and adapters to be able to mount/remount Rum components in a React Native application.") "Helpers and adapters to be able to mount/remount Rum components in a React Native application.")
(def React (js/require "react-native")) (def React (js/require "react"))
(def create-class (.-createClass React)) (def create-class (.-createClass React))
(def create-factory (.-createFactory React)) (def create-factory (.-createFactory React))