reagent

2023-03-29T09:29:54.853339Z

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.

tomd 2023-03-29T09:31:14.767459Z

(ns foo
         (:refer-clojure :exclude [list]))

πŸ™ 1
Clojuri0an 2023-03-29T19:35:47.881239Z

How do I prevent default form submission in the way of

event.preventDefault();
Can't find in documentation

p-himik 2023-03-29T19:36:34.558169Z

Have 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.

πŸ‘ 1
p-himik 2023-03-29T19:37:26.492449Z

In React, you'd attach an even handler that cancels the event as onSubmit. In Reagent, it would be :on-submit or :onSubmit.

Clojuri0an 2023-03-29T19:46:17.059849Z

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.

Clojuri0an 2023-03-29T19:46:55.936899Z

(most relevant section is under defn stripe-checkout-form at :on-submit

thheller 2023-03-29T19:47:18.664149Z

don't do this :on-submit #(-> (do, use a regular fn, which also makes it obvious where your event is

thheller 2023-03-29T19:47:27.488919Z

so :on-submit (fn [event] ...)

thheller 2023-03-29T19:47:55.380889Z

(.js/preventDefault %) is not valid, it would be (.preventDefault %) or with the fn (.preventDefault event)

thheller 2023-03-29T19:48:34.289649Z

also whatever else you are doing there is wrong, but I'll let you figure that out

p-himik 2023-03-29T19:53:07.009029Z

@nanidatofan99 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.

Clojuri0an 2023-03-29T19:58:05.850399Z

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

p-himik 2023-03-29T19:59:51.149569Z

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.

βž• 2
Clojuri0an 2023-03-29T20:01:45.571539Z

Ok I'll do this part in react, you can import clojurescript as a module right and then call elements from it?

Clojuri0an 2023-03-29T20:02:12.319209Z

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

p-himik 2023-03-29T20:04:46.087239Z

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.

Clojuri0an 2023-03-29T20:09:40.485679Z

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

Sam Ritchie 2023-03-29T20:14:44.212709Z

Hint - it is really good advice!!!!!

Clojuri0an 2023-03-29T20:43:29.202189Z

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.

Sam Ritchie 2023-03-29T20:44:57.758239Z

Ah, got it. That is great too but trying to pull in cljs to raw js as a first experience might be tricky

Clojuri0an 2023-03-29T20:46:08.891759Z

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

Sam Ritchie 2023-03-29T20:46:37.504519Z

Haha you’re in good company here in software world!

Clojuri0an 2023-03-29T20:50:04.002889Z

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

p-himik 2023-03-29T20:52:32.720009Z

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.

πŸ‘ 1
Clojuri0an 2023-03-29T20:57:44.429669Z

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

p-himik 2023-03-29T21:00:32.479389Z

> importing cljs into react Assuming that means what I think it means, IIRC that's a path of pain and trouble. Search around in #clojurescript, #reagent, and maybe #shadow-cljs to learn why.

Clojuri0an 2023-03-29T21:10:26.738499Z

@p-himik I'll check it out, ty. Gonna go touch grass and lift weights

πŸ‘ 1
Clojuri0an 2023-03-30T06:01:05.612229Z

I think you're right @p-himik 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

πŸ‘ 1