This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-03-29
Channels
- # admin-announcements (1)
- # announcements (20)
- # babashka (43)
- # beginners (134)
- # calva (2)
- # clerk (7)
- # cljdoc (9)
- # clojars (8)
- # clojure (91)
- # clojure-europe (21)
- # clojure-nl (1)
- # clojure-norway (13)
- # clojure-uk (1)
- # clojurescript (5)
- # datahike (3)
- # docker (2)
- # emacs (6)
- # fulcro (7)
- # graphql (9)
- # honeysql (24)
- # improve-getting-started (5)
- # introduce-yourself (1)
- # lambdaisland (1)
- # luminus (3)
- # malli (3)
- # nbb (19)
- # off-topic (22)
- # pathom (1)
- # portal (3)
- # practicalli (1)
- # rdf (26)
- # reagent (29)
- # reitit (9)
- # shadow-cljs (15)
- # spacemacs (3)
- # sql (4)
- # tools-build (30)
- # xtdb (41)
How can I get rid of this warning:
20 |
21 | (def list (r/adapt-react-class (.-default JoyList)))
-------^---------------------------------------------------------
list already refers to: cljs.core/list being replaced by: joy-ui/list
-----------------------------------------------------------------
I understand what it's saying. Don't care. Want it to go away. I'm happy to refer to list
by cljs.core/list
if I ever need it in that component.How do I prevent default form submission in the way of
event.preventDefault();
Can't find in documentationHave you read CLJS docs on JS interop?
You just get your hands on that event
and call the preventDefault
function on it. Only not in JS but in CLJS.
In React, you'd attach an even handler that cancels the event as onSubmit
. In Reagent, it would be :on-submit
or :onSubmit
.
Yes, I read it. I'm confused because I wasn't thinking of it in terms of events. So, I'm not sure where the event is anymore. I attached a codeblock of my code, but it seems to still refresh. I think I'm confusing the event with the promise returned by the event.
(most relevant section is under defn stripe-checkout-form at :on-submit
don't do this :on-submit #(-> (do
, use a regular fn
, which also makes it obvious where your event is
(.js/preventDefault %)
is not valid, it would be (.preventDefault %)
or with the fn
(.preventDefault event)
@U04K4MMEB2S Given your code, I feel like you're in dire need of the following advice: take a step back and start with a smaller project. Don't integrate Stripe, don't use hooks, don't use promises, and anything else that goes beyond what's mentioned in the Reagent "getting started" docs. Even that by itself will be more than enough because it'll contain JS+CLJS+React+Reagent+HTML+CSS, different parts to different extent. Go step by step, don't try to tackle everything all at once. Otherwise, you'll keep ending up with code similar to the above, where, frankly, most of the lines are wrong.
It would be nice to do that but I need to make this specific thing quickly, do you think I should just do it in react
When you need to do something quickly, you should stick to what you know instead of trying to learn a new thing along the way. Especially when that "thing" is actually multiple things.
Ok I'll do this part in react, you can import clojurescript as a module right and then call elements from it?
I find it difficult to make time to do things outside of existing projects so might be better to just do simple components in cljs
Actually, it will be harder that way. Whenever you have time, work on a tiny independent CLJS project. Don't try to shoehorn CLJS where it doesn't belong. As time goes on, build upon that project organically, adding new technologies only when you're sure that you're more or less familiar with what you already have. Familiar not in terms of the specific code that you've written but in terms of the technologies that you've used.
That's not really how I think or do things usually. Not sure if it's just what I don't want to hear or if it doesn't work for me, but I'll consider your advice
Hint - it is really good advice!!!!!
It's not something that has ever worked for me. I generally try to do as much as I possibly can in what I am trying to learn. E.g., if I'm learning a foreign language, I set the system language in it to force me to deal with the unknown.
Ah, got it. That is great too but trying to pull in cljs to raw js as a first experience might be tricky
I'm not saying it's bad advice, but I have a number of personality flaws that other people in my genealogy also suffer from. Namely, being arrogant, stubborn, a bit dull etc
Haha you’re in good company here in software world!
It's a bit painful to look at vanilla JS after using cljs, I feel like I'd like to try to make simple parts of the UI in cljs and anything more complex in react
Natural languages are very different from the programming ones. The former are relatively constrained when all you need is for a language to be useful to you. The latter are practically unbounded because they include not just a particular language itself but its whole ecosystem. Which is most of the time all too large for a single person to just consume. Also, you already have all the context you need to learn a new natural language. Whereas you don't have all the necessary context to learn a new technology if it relies on something you don't yet know.
I honestly just don't know if it's going to be cognitively possible to peel myself away from this, I've spent so much time over the past few days on it. I do need to setup importing cljs into react though since the code-base this is a part of is part of reagent, so might be able to fork my mind off fixating on this one specific thing by framing it as learning to integrate what I've made so far with the existing react app
> importing cljs into react Assuming that means what I think it means, IIRC that's a path of pain and trouble. Search around in #C03S1L9DN, #C0620C0C8, and maybe #C6N245JGG to learn why.
I think you're right @U2FRKM4TW this does not appear trivial to do, I ended up just implementing this stuff in react directly since I could copy/paste the stripe code it was a lot faster. I think that objectively what I tried to do was probably too ambitious for my current skill level, and I'm not sure cljs is the best tool for this part of the app. But I'll keep on building the node backend with clj since it seems to work so far