Fork me on GitHub
#cljsrn
<
2020-07-11
>
Luca20:07:57

Hi everyone, I am moving my very first steps with the cljsrn stack, I think I am missing some basics.. I am trying to use reagent to make adapt the react native class but I am doing something wrong, can anybody help me with the right conversion? Thank you in advance!

(ns awesome.main
  (:require [react]
            [reagent.core :as r]
            [react-native :as rn]))

(def <> react/createElement)

(defn example-component []
  (<> rn/View
      #js {:style #js {:backgroundColor "#FFFFFF"
                       :flex            1
                       :justifyContent  "center"}}
      (<> rn/Text
          #js {:style #js {:color     "black"
                           :textAlign "center"}}
          (str "hello WORLD!!"))))

(def view (r/adapt-react-class rn/View))
(def text (r/adapt-react-class rn/Text))

(defn reagent-component []
  [view {:style {:backgroundColor "#FFFFFF"
                 :flex            1
                 :justifyContent  "center"}}
   [text {:style {:color     "black"
                  :textAlign "center"}} "Hello!"]])

Luca20:07:53

Is it rather something like this?

(defn reagent-component []
  [:> rn/View {:style {:backgroundColor "#FFFFFF"
                 :flex            1
                 :justifyContent  "center"}}
   [:> rn/Text {:style {:color     "black"
                  :textAlign "center"}} "Hello!"]])