Fork me on GitHub
#reagent
<
2018-03-14
>
eoliphant23:03:09

anyone using react-sticky with reagent? I’ve been trying to use the cljsjs version(s) to no avail. I found some stuff in the archive from @gadfly361 that led me to try downgrading from the 6.x version to 5.x but still no joy. after requiring cljsjs.react-sticky the js/ReactSticky ref is nil

justinlee23:03:54

@eoliphant either (1) include the UMD build with a script tag and then references the global object, (2) use :foreign-libs, (3) consider using shadow-cljs, where you can just install it via yarn/npm and include it

eoliphant23:03:25

ok justin will give that a shot. Been wanting to switch to shadow, but it’s was kind of a pain trying to get it all workiing with my current project’s setup..

justinlee23:03:30

here were my notes-to-self when I was figuring all of this stuff out. it probably isn’t really all correct but it might help https://gist.github.com/jmlsf/f41b46c43a31224f46a41b361356f04d

justinlee23:03:27

if you already have a lein project, i believe you can just let lein do dependencies and just embed shadow in lein

eoliphant23:03:36

yeah your (1) is me at the moment lol

eoliphant23:03:37

yeah I tried that, got it sort of working

eoliphant23:03:17

but this project was created with luminus

eoliphant23:03:22

i forgot the guy’s handle, the shadow author, he was helpful, but it was still a pain to get it working. need to do some refactoring on my project.clj

justinlee23:03:39

that thheller. there’s also a #shadow-cljs channel

eoliphant23:03:54

that’s where I was workign with him on it

justinlee23:03:31

so if you don’t want to go with shadow right now, I still think the the best route is to setup :foreign-libs and then do all your accesses with cljs-oops. One thing to investigate: you might not even really need to use cljs-oops if you turn on externs inference and make sure to turn on warnings and then type hint. My understanding is that shadow does this in a bette way.

eoliphant23:03:14

yeah, i’d been reading that. I’m hoping one day, this all makes it into the native builder. I love clojure(script) but this stuff is a pain lol.

eoliphant23:03:37

I saw the 1.10 beta was out, wasn’t clear from the docs that are available how much, any of this stuff has been improved

justinlee23:03:02

right. the messaging around externs inference is frustratingly vague

eoliphant23:03:37

yeah and the npm-deps stuff was just an annoying tease lol

eoliphant23:03:17

hey so one thing. I’m under a time crunch so just gonna do whatever works fastest lol. So, my project is reagent, etc via cljsjs

eoliphant23:03:25

if I say try the UMD route

eoliphant23:03:13

i guess there’s a chicken/egg issue since reagent and all gets wrapped up into my app.js

eoliphant23:03:34

but my app.js needs the code i’m pulling in

justinlee23:03:11

i think that’s fine. if react and reagent is all working and you just want to add in react-sticky, just <script> include the UMD build

justinlee23:03:20

or :foreign-libs include it

eoliphant23:03:02

ok but won’t the <script> fail if it’s pulled prior to my app code?

eoliphant23:03:16

yeah looking at foregin libs now

justinlee23:03:22

yea i’m not sure about that

gadfly36123:03:12

@eoliphant I am using react sticky with reagent 6.1 and react 15.4 and it is working for me

eoliphant23:03:30

yeah I saw your note in the archive

eoliphant23:03:33

it’s really weird

eoliphant23:03:43

i was on the 6.x or whatever

eoliphant23:03:51

but have gone down to 5

eoliphant23:03:13

[Rebel readline] Type :repl/help for online help info
To quit, type: :cljs/quit
app:cljs.user=> (require '[cljsjs.react-sticky])

app:cljs.user=> js/ReactSticky
nil
app:cljs.user=> 

gadfly36123:03:01

(i dont remember what I said regardning this topic 😆 )

;; in project.clj
  :dependencies [[org.clojure/clojure "1.8.0"]
                 [org.clojure/clojurescript "1.9.456"]
                 [reagent "0.6.1" :exclusions [[cljsjs/react-dom]
                                               [cljsjs/react]]]
                 [cljsjs/react "15.4.0-0"]
                 [cljsjs/react-dom "15.4.0-0"]
                 [cljsjs/react-sticky "5.0.8-0"
                  :exclusions [[cljsjs/react-dom]
                               [cljsjs/react]]]
(ns foo.bar
   (:require 
     [cljsjs.react-sticky]
     ...)

(def sticky-container (reagent/adapt-react-class (aget js/ReactSticky "StickyContainer")))
(def sticky (reagent/adapt-react-class (aget js/ReactSticky "Sticky")))

gadfly36123:03:36

if you use those versions and still not working, id guess it is something else

eoliphant23:03:45

hmm the only diff

eoliphant23:03:56

is that i’m on reagent 0.7.0

justinlee23:03:22

@eoliphant what exactly isn’t working?

gadfly36123:03:41

sounds like no access to js/ReactSticky

eoliphant23:03:47

js/ReactSticky

eoliphant23:03:54

should eval to an object or something

justinlee23:03:29

I know this is stupid but you definitely have the right :require?

eoliphant23:03:50

yeah tried it even from the figwheel repl

eoliphant23:03:57

just to make sure

eoliphant23:03:01

just the require

eoliphant23:03:15

and tried to reference it

eoliphant23:03:35

the weird thing

eoliphant23:03:42

is that i guess the extern or whatever is ‘working’

eoliphant23:03:55

because js/ReactSticky evaluates to nil

eoliphant23:03:06

as opposed to me getting a complaint

eoliphant23:03:20

about ReactSticky not being defined

justinlee23:03:21

have you looked at the top of whatever file you are including via foreign-libs to make sure it is actually a UMD build?

justinlee23:03:26

oh you’re doing this vs cljsjs

justinlee23:03:41

cljsjs is frustrating because there are so many layers I don’t know what it is doing

gadfly36123:03:30

@eoliphant for completeness, have you killed and restarted figwheel ? (Rather than reload-config)

eoliphant23:03:51

did lein clean

eoliphant23:03:57

then lein figwheel again

gadfly36123:03:10

Figured, just making sure lol

eoliphant23:03:31

I’ve gathered that this is a knotty problem for the ecosystem. I’m gonna have few shots when ‘cljs install whatever’ just works

eoliphant23:03:05

it seems like shadow is the closest