squint

m3tti 2025-04-15T07:34:23.536219Z

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
m3tti 2025-04-15T07:46:47.645819Z

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

borkdude 2025-04-15T08:06:15.303979Z

symbols don't work in squint

borkdude 2025-04-15T08:06:20.918539Z

they don't exist at runtime

m3tti 2025-04-15T08:06:40.184459Z

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)
😄

borkdude 2025-04-15T08:06:58.310179Z

👍

m3tti 2025-04-15T08:07:19.370739Z

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

borkdude 2025-04-15T08:07:30.929939Z

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

m3tti 2025-04-15T08:07:44.917599Z

yeah saw it allready 😄

m3tti 2025-04-15T08:08:02.429719Z

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

borkdude 2025-04-15T08:08:17.064429Z

:)