Set of useful helpers and wrappers around React Native for ClojureScript development
(ns app.core
(:require [ktoa.components :refer [component] :as c]
[ktoa.core :refer [run-app!]]))
(def child
(component
{:render #(this-as that
(c/text nil that.props.title))}))
(def parent
(component
{:render (fn[](this-as that
(c/view {}
(child {:title that.props.title})
(map #(c/text {:key %} %) (range 20)))))}))
;; Feel free to reeval following line - ktoa will refresh application
(run-app! "app" parent {:title "\n\nHello"})
react-native- Returns requiredreact-nativemodulereact- Returns requiredreactmoduleos- Returns nil for non react-native environments or:iosor:androiddepending on current platformrun-app!(app-name component override-props)- If application wasn’t mounted before - simply register it, otherwise rerun it with (optionally) supplied arguments. Usefull for REPL driven development - just re-evalrun-app!call with initial props
class(ops)- Wrapper aroundReact.createClasselement(element opts & children)- Wrapper aroundReact.createElementcomponent(opts)- Convenient wrapper for creating your own components like:
(def hello
(component
{:render (fn[](this-as that
(c/text {} this.props.msg)))}))
;; Later on you can compose it with other components
(def wrapper
(component #(c/view {}
(c/text {} "Hello")
(hello {:msg "World"}))))
;; Or you can use it as a root component for the whole application
(ktoa.core/run-app! "[name-of-app]" wrapper)
;; Alternativly just call it from any place in your project to play with new ideas
(ktoa.core/run-app! "[name-of-app]" (component {:render #(c/text {} "debug me")}))
- This namespace currently exposes following wrapped with
elementReact Native components:activity-indicatorbuttondate-picker-iosdrawer-layout-androidimagekeyboard-avoiding-viewlist-viewmap-viewmodalnavigatorpickerpicker-iosprogress-bar-androidprogress-view-iosrefresh-controlscroll-viewsegmented-control-iossliderstatus-barswitchtab-bar-iostab-bar-ios-itemtexttext-inputtoolbar-androidtouchable-highlighttouchable-native-feedbacktouchable-opacitytouchable-without-feedbackviewview-pager-androidweb-view
Early development, experimenting with right lib design. There are a
lot of discussion happens in http://clojurians.net, on #cljsrn
channel. Feel free to join
- https://github.com/drapanjanas/re-natal - Quick start templates for different frameworks and some tooling around
- https://github.com/mjmeintjes/boot-react-native - If you are into Boot
Big thanks to decker405 and his awesome idea how to use Figwheel with RN: https://github.com/decker405/figwheel-react-native