squint 2025-04-15

i have some issues with react-native if i use functions from squint core or better squint defaults like case or atom react says it can't find the cljs object. even when squint-core is importet. Anyone encountered something like this?

✅ 1

ah the issue is not atom itself or case its symbol like it seems

symbols don't work in squint

they don't exist at runtime

ahhhh thanx 😉 now everything works like a charm and man i love it

(ns App
  (:require
   ["react" :refer [useState]]
   ["react-native" :refer [Text View StyleSheet StatusBar Button]]))

(def initialState {:route "home"})

(def styles (StyleSheet.create
             {:container {:flex 1
                          :backgroundColor "#2d2d2d"
                          :alignItems "center"
                          :justifyContent "center"}}))

(defn- TestView [{:keys [state setState]}]
  #jsx [View {:style styles.container}
        [Text "Hello"]
        [Button {:onPress #(setState {:route "home"}) :title "Home"}]
        [StatusBar {:style "auto"}]])

(defn- HomeView [{:keys [state setState]}]
  #jsx [View {:style styles.container}
        [Text {:style {:color "#ffffff"}} "Droem 2.0"]
        [Button {:onPress #(setState {:route "test"}) :title "Test"}]
        [StatusBar {:style "auto"}]])

(defn- App []
  (let [[state setState] (useState initialState)]
    (case (:route state)
      "home" #jsx [HomeView {:state state :setState setState}]
      "test" #jsx [TestView {:state state :setState setState}])))

(def default App)
😄

i have another pet project my lucid dream app that i did 10 years ago but this time with squint with react native 😄

you could use a keyword instead of a string (since they compile both to a string) :)

yeah saw it allready 😄

thats how i get used to squint having open the squint source and the js 😄