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-native
modulereact
- Returns requiredreact
moduleos
- Returns nil for non react-native environments or:ios
or:android
depending 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.createClass
element(element opts & children)
- Wrapper aroundReact.createElement
component(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
element
React Native components:activity-indicator
button
date-picker-ios
drawer-layout-android
image
keyboard-avoiding-view
list-view
map-view
modal
navigator
picker
picker-ios
progress-bar-android
progress-view-ios
refresh-control
scroll-view
segmented-control-ios
slider
status-bar
switch
tab-bar-ios
tab-bar-ios-item
text
text-input
toolbar-android
touchable-highlight
touchable-native-feedback
touchable-opacity
touchable-without-feedback
view
view-pager-android
web-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