Fork me on GitHub
#reagent
<
2018-05-03
>
tomaas07:05:30

Hi. In the ratom.cljs file there is a make-reaction function which returns an instance of Reaction type (->Reaction f nil true false nil nil nil nil), where f is reagent render function. I can't see/understand how an referenced atom inside that f render function causes the f to execute (causing the rerender). In general add-watch function sets some function to execute when some atom changes. Based on this, i can only think that when creating a reaction the f function should be parsed as list data structure, all atoms in it should be found and watches then set on those atoms indicating to execute that f function when they change.

plexus09:05:17

Anyone seen this: reagent.dom.node$module$react_dom is undefined?

plexus09:05:17

Just started a brand new Reagent project, lein new figwheel => add reagent and bump clojurescript to latest, and now I get this

plexus09:05:48

seems it's trying to use reagent/reagent-dom from npm-deps, whereas I'd be happy if it just used cljsjs

plexus09:05:49

managed to get it working by adding the latest react/react-dom packages. reagent 0.8.0 depends on 16.3.0-1, whereas it worked with 16.3.2-0

juhoteperi09:05:12

@tomaas Reagent catches all RAtom deref calls during render and adds watches from components to the ratom

juhoteperi09:05:51

or watch from other ratom to another

juhoteperi09:05:10

the deref method uses dynamic var to keep track of the context

juhoteperi09:05:35

e.g.

(defn foo-component []
    (if @a-ratom
       [:h1 @b-ratom]
       [:div @c-ratom]))

juhoteperi09:05:56

Reagent will only watch a-ratom, and then b or c depending on a state

tomaas09:05:00

got it! thanks a lot @juhoteperi!

athomasoriginal15:05:29

Getting the following error when trying to upgrade from reagent .7 to .8

No such namespace: react, could not locate react.cljs, react.cljc, or JavaScript source providing "react"

athomasoriginal15:05:47

Seems like it just cannot find react

Tom H.16:05:38

What environment are you targetting?

Tom H.16:05:49

Hmm may need to provide React directly via cljsjs? I'm not sure why though

athomasoriginal16:05:21

Yeah, looking into the cache

athomasoriginal16:05:41

got it to build...all the cljsjs/* deps needed to be upgraded

juhoteperi16:05:52

As mentioned in the guide: > Using Reagent with Cljsjs packages doesn't require changes, other than making sure you update Cljsjs React dependencies, if you have direct dependencies to them. Also, using other packages depending on Cljsjs/React could cause one to have old version.

lwhorton18:05:48

huh .. i just noticed that an element [foo {:style {:background-image ...}}] causes react to complain did you mean "backgroundImage", but it still works? does reagent not kebab->camelCase :style maps?