This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-05-13
Channels
- # aleph (6)
- # announcements (10)
- # asami (3)
- # babashka (111)
- # babashka-sci-dev (20)
- # beginners (28)
- # calva (28)
- # clj-http (1)
- # clj-kondo (23)
- # cljs-dev (16)
- # cljsrn (23)
- # clojure (116)
- # clojure-czech (3)
- # clojure-europe (33)
- # clojure-nl (1)
- # clojure-norway (7)
- # clojure-uk (5)
- # clojurescript (41)
- # community-development (2)
- # cursive (5)
- # datahike (4)
- # datomic (13)
- # figwheel-main (3)
- # fulcro (11)
- # google-cloud (1)
- # gratitude (8)
- # hyperfiddle (14)
- # jobs (2)
- # lsp (22)
- # malli (4)
- # off-topic (4)
- # other-languages (4)
- # pathom (13)
- # portal (40)
- # rdf (11)
- # reitit (1)
- # sci (15)
- # shadow-cljs (7)
- # specter (1)
- # sql (6)
- # xtdb (4)
Can anyone point me in the right direction of how to store react navigation such that the navigation stack isn't lost on reload (in an expo/shadow-cljs project if that matters)? I have been trying to store the ref from react-native/NavigationContainer in an atom along with the result of .getRootState on that ref and then restoring it with .resetRoot but have not been successful doing that. I end up with an exception on reload within .resetRoot, but I'm not confident enough in my approach to really start digging into react native source when I'm not even certain I'm thinking about this the right way
To persist nav state you could also pass {:onStateChange on-state-change :initialState @state}
to NavigationContainer.
The code for persisting state could look like:
(defonce state (atom nil))
(defn- persist-state! [state-obj]
(js/Promise.
(fn [resolve _]
(reset! state state-obj)
(resolve true))))
(defn- on-state-change [state]
(persist-state! state))
And for storing the ref, you could use useNavigationContainerRef
hook to get the ref.That works! Thank you 🙂 I had really been struggling with this. Strangely my app crashes if I have a modal open while making code changes but that could very well be due to something I've done.
Just incase anyone else can benefit from my mistakes, I was previously trying to use the following references:
1. https://gist.github.com/olivergeorge/981bc5135fa47253cba50fd125495d0b
a. The approach I used in my original post
2. https://github.com/eihli/cljs-react-native-starter/blob/master/src/example/core.cljs
a. Uses persistNavigationState
and loadNavigationState
I'm not sure why 1) did not work, but 2) is now out of date from what I can tell reading the React Navigation docs. As someone who wasn't already familiar with react and was simply reading through repos cljs/react native repos for ideas, it was tough to know what was actually still usable in the latest version of react native so I hope this saves someone else some time 🙂
You can persist it using local storage from expo, each time you navigate, persist the new route and read it when creating the stacks. This also helps in the case when the user closes the app and when opens it, you can show them the previous visited screen
Hey all! I'm currently working on throwing together a template project for my company that uses Krell+Storybook out-of-the-box, since I hadn't seen anything publicly available that combined that stack (despite it's popularity in this channel 😉 ). While reading through some of the troubleshooting, I noticed that a handful of people were trying to get Krell to work with react-native-web
(specifically @hkjels) and I was curious if anyone had made any progress getting that put together.
I've currently tried futzing around with Webpack (based on the instructions here https://necolas.github.io/react-native-web/docs/multi-platform/) to no avail, and also scouring around Expo's source code to recreate whatever they have going on, but my JS comprehension skills are sorely lacking. Any guidance anyone can offer in that direction is much appreciated 🙂
The repo is here: https://github.com/loganrios/ksapp. Let me know if it looks useful!
@U03DKTAF52P Awesome! I have been meaning to get into Storybook, this helps a lot.
In your README you say you need Clojurescript but don’t remember how to get it — it’s just a dep. You don’t need to do anything. Requiring krell in deps.edn
transitively requires it.
As far as Storybook goes, I'm currently fighting how to best create JSX components and their stories while still using them in CLJS. Based on what I've read in this channel from @U050B88UR, it appears that Krell doesn't do relative-path import
s like you would in normal RN. There was some rumor about it being less discriminating about where Krell looked for node_modules
(such that I assume you could add it to a top-level components
folder or something...), but I haven't been able to get it to play nice. Per @U050KSS8M, apparently creating your own local NPM module and slotting it into package.json
works well so maybe that's the best we got 🤷
I was able to tweak metro to bundle correctly, so advanced builds work. I’m now looking more into how the internals of Krell and Figwheel works to see if I can port the missing pieces from figwheel to krell. I also need some weird functionality for my project though, so I don’t expect to have a general solution in place any time soon. It's also just a pastime project
I’ll make a gist on Monday. I’m currently on a bachelorparty and nowhere near my laptop
https://gist.github.com/hkjels/f1938e7b3f89f929cbd071f490c55c6d Sorry for the late reply
@U03DKTAF52P I've done a small react-native-web project, but I've been using figwheel-main. It worked without any specific problems that I recall (I can REPL to the running browser). I believe I started from the project as an expo bare project. I recall trying to add react-native-web to an existing (older) react-native project and that seemed to be much more of a hassle.
@U050KSS8M did you then use krell for regular react-native stuff?