reagent

A minimalistic ClojureScript interface to React.js http://reagent-project.github.io/
arielalexi 2021-06-28T14:22:53.131900Z

Hey everyone, I am trying to work with reagent in my project, and it seems like something is broken. (ns learn-fe (:require [reagent.core :as r])) => nil I am working from an empty project and not from a template project. when I try to user reaget in my code, I am getting the error (below) and when I looked inside reagent ns - I don't see all the function reaget should have.

; Execution error (FileNotFoundException) at learn-fe/eval37225$loading (REPL:1).
; Could not locate Reagent/core__init.class, Reagent/core.clj or Reagent/core.cljc on classpath.
deps.edn is update with the reagent version - reagent/reagent            {:mvn/version "1.0.0"} I would be happy to get some help why the requried dependency is empty

sansarip 2021-06-28T14:33:22.132200Z

That screenshot is from the reagent.core clj namespace and contains the with-let macro definition and looks correct. If you look at the reagent.core cljs namespace it should contain the “missing” functions. It’s hard to say what the issue is without looking at your deps.edn :thinking_face:

sansarip 2021-06-28T14:40:05.132600Z

Sorry if this is a silly question, but you are attempting this (requiring reagent.core) from a cljs namespace/cljs REPL, right?

Lu 2021-06-28T14:53:45.133700Z

If you can link the repo it’s much easier to see what the problem is. Especially since you just started :)

2021-06-28T15:02:01.136800Z

Hi! I’m currently discovering Reagent and I’m trying to understand how it handles re-rendering under the hood. For instance in the case of a form-2 component with a ratom, how is it translated into React code ? Does it use setState/getState internally (or useState with the new functional compilation) ?

p-himik 2021-06-28T15:05:26.136900Z

The error: Could not locate Reagent/core__init.class Notice how it says Reagent instead of reagent. Clojure[Script] is case-sensitive, so make sure your :require vector has the lower-case word.

juhoteperi 2021-06-28T15:14:09.137100Z

Class components use forceUpdate and functions use useState (https://github.com/reagent-project/reagent/blob/master/src/reagent/impl/component.cljs#L402_L413)

2021-06-28T15:42:49.137400Z

Thanks! I have to dive into the code, not that easy 😅

arielalexi 2021-06-28T16:18:11.137600Z

https://github.com/ArielA147/leran-clojure-script @p-himik I used reagent in lower-case letters.

p-himik 2021-06-28T16:22:24.137900Z

Alright. And how exactly are you trying to compile/run the code?

p-himik 2021-06-28T16:30:16.138100Z

Issues with that repo: • No ClojureScript dependency specified • The only source file uses cebab-case instead of snake-case. In Clojure, if you have a namespace a-b, then the file has to be named a_b, followed by an appropriate extension • clj -M --main cljs.main --compile learn-fe (the simplest way to build CLJS) fails when evaluating the lambdaisland require. It works fine if I leave only the Reagent require