Clojurescript + react native (Android)
1 Clojurescript + react native (Android)
Dev mobile apps with linux written mainly in clojurescript.
1.1 Setup with shadow-cljs (dec 6 2019)
1.1.1 create a react-native project
react-native init <ProjectName> cd <ProjectName>
1.1.2 delete the file App.js
This may change in the future. For now we use index.js
1.1.3 replace index.js with the following content
import "./build/index.js"
1.1.4 create the shadow-cljs.edn file with following content
Change your dependecies as you require.
{:source-paths ["src/main" "src/test"] :dependencies [[org.clojure/core.async "0.4.474"] [cljs-http "0.1.46"] [re-frame "0.11.0-rc3"] [reagent "0.9.0-rc3" :exclusions [cljsjs/react cljsjs/react-dom cljsjs/react-dom-server cljsjs/create-react-class]]] :builds {:app {:target :react-native :init-fn <project-name>.core/init :output-dir "build" :devtools {:autoload true}}}}
not to sure if all the exclusions are needed
1.1.5 write some code in src/main/project-name.core.cljs init
Like…
(defn init [] (dispatch-sync [:initialize-db]) (.registerComponent app-registry "geocoder" #(r/reactify-component app-root)))
1.1.6 For development
shadow-cljs watch app react-native start react-native run-android
1.1.7 Build apk
shadow-cljs release app cd android ./gradlew build