This is what I would typically do in a work project.
• For shadow-cljs imports where the typical JS import syntax is import { Alert } from 'react-native';
I use :refer
to get the same effect. I've found it helps newcomers to clojure from Javascript to see syntax that's visually similar.
• When styles are shared, I'll use a def
statement so I can merge them in different components. Generally though, I stay away from the Stylesheet.create
paradigm, and try to define the styles close to the elements they target instead.
• With that, I break up components into smaller molecules, which helps when not using Stylesheet
.
By the way, @jimberlage, what do you think of the setup of the core.cljs file? Am I initiating my app correctly? :o
I'll take a look a bit later and do the same thing I did for this file for ya
Wow thank you! Much appreciated! That is awesome!
Alright that is great! I will make the appropriate changes! 😄
Do you use Reanimated and Gesturehandler? I am not quite sure how to get those into my project and begin using them. The examples online are also kind of lackluster. I have setup my project with NPM but online they want to use yarn to add these modules. And as I understand it, we shouldn't use both yarn and npm for packages, right?
@shakof91 I’d stick to yarn for React Native; I don’t have scientific proof for it, but it has been better than npm in my experience
I have also used Reanimated/Gesturehandler, they are quite good, but only go for them if you really have the use case for them
I want to explore them and kind of write up how to use them. How did you import them into your project? Any steps that need to be taken? I see there is something about linking the packages etc. I don't quite understand what that means. I will also restart my project with yarn this time.
Linking should be mostly taken care of on newer versions of react-native. Basically, some of the objective-c and java files needed to be told about the existence of objective c and java files in libraries you imported. Now, react-native has an automated way to do that.
Ah ok. So as long as I run that link command, it should be taken care of? I am using the cutting edge versions of react and react native. ^^
Yeah, linking shouldn't be a thing you have to consciously run a command to do on new versions of react native. If a library doesn't support auto-linking, they usually call it out in their readme
Alright. I understand. Thank you!
All right the Reagent tutorial for Krell is done - https://github.com/vouch-opensource/krell/wiki/Reagent-Tutorial
I tested that hot-reloading, production build works - I didn't try every combination simulator/device but I'm sure I'll hear from people if something doesn't work
as far as features, I'm not sure there is going to be much more - but if you're really itching for something, let me know
my main priority on this project will be to be keep the feature set small and work on performance
I think we can make simpler version of Metro's cache on device and that would help w/ shorter time to see the app and getting to actually hacking w/ a REPL
oh and another thing, I'm not interested in flags or options for the entry point
I just think that kind of customization is gratuitous
just return your component from -main
that's already a convention
there's also no real need for integration - the reloader is in the Krell root - so as long your ClojureScript React libs returns a component - there's nothing to do
Thank you for your work @dnolen I’ve already gave it a spin and I like what you’ve done!
👍:skin-tone-4:
@shakof91 I think this would work for you:
• reagent.core/reactify-component I think does a lot of the heavy lifting to simplify this file.
• I removed the refs - but perhaps you needed them to enforce executing only once? You can also store a :first-run?
flag in the DB if that will persist across reloads, to get the same effect.
• As a personal taste thing, I usually remove the brackets around namespaces I'm loading for side effects. It makes them stand out visually
Thank you very much! I will test this out. This looks sooo much better! Also, I actually didn't know you could call rf/dispatch-n. I always wrapped that and dispatch-later in an event. Wow I feel dumb ><
@dnolen I'm hitting an error with the production build step in the tutorial. I wondered if it was a constant folding thing but same error occurs with simple both advanced targets.
TypeError: undefined is not an object (evaluating 'Z.unstable_cancelCallback')
<anonymous>
main.js:224:85
<anonymous>
main.js:57:86
<global>
main.js:57:13
loadModuleImplementation
require.js:321:11
<global>
index.js:10
loadModuleImplementation
require.js:321:11
guardedLoadModule
require.js:201:44
global code
index.bundle?platform=ios&dev=true&minify=false:176206:3
Stand down red alert. I re-did the tutorial and it's working.
This was the only change. Yeah, confirming that caused the error.
- reagent {:mvn/version "0.10.0"}}}
+ reagent {:mvn/version "0.10.0"
+ :exclusions [cljsjs/react cljsjs/react-dom]}}}
yeap