Fork me on GitHub
#shadow-cljs
<
2020-01-07
>
knubie01:01:42

Has anyone gotten react native to work with shadow-cljs without expo?

Eric Ihli11:01:14

Yeah I'm using it. Running into any particular issue @steedman87?

knubie14:01:16

Was running into some issues / confusion around how to structure the app. This example project is really helpful, thanks @thheller!

knubie16:01:32

Running into another react-native issue that may not be specific to react native.

knubie16:01:51

The conditional at the top should be false (because cljs.core/*target* returns “react-native”

knubie16:01:29

but I’m still getting an error when running my code: Unable to resolve module xmlhttprequest from …

knubie16:01:13

I’m pretty sure that snippet of code is the culprit because I copy and pasted it into my code without including the lib and got the same error

knubie16:01:47

React native comes with xmlhttprequest, so the else branch should be able to run find (https://facebook.github.io/react-native/docs/network.html)

thheller16:01:04

require is a compile time construct in react-native

thheller16:01:19

therefore the compiler (metro) will try to resolve it and fail at compile time. it never gets to runtime.

thheller16:01:14

there might be some way to tell metro to ignore it but I don't know. check with someone that actually uses react-native 😛

knubie16:01:43

that makes sense, thanks. I’ll do some more digging

knubie17:01:53

maybe it’s possible to just make a shim somehow?

danielneal17:01:19

strange, for me js/XMLHttpRequest returns the right thing

danielneal17:01:26

and that snippet of code takes the correct branch

danielneal17:01:33

which version of react native are you on?

thheller17:01:03

the isn't about js/XMLHttpRequest at all

thheller17:01:50

this is about react-native metro trying to include the (js/require "xmlhttprequest") since its done at compile time and it doesn't recognize the conditional

danielneal17:01:06

ah of course

knubie18:01:59

Creating a shim and declaring it in extraNodeModules in metro.config.js seems to have done the trick.

parrot 4
Brian Abbott19:01:37

Do users of Shadow-CLJS also integerate with FigWheel?

Brian Abbott19:01:54

or do we see it as one vs the other?

Brian Abbott19:01:13

well, fig has the cool dom updater. But, maybe Shadow does that as well?

lilactown19:01:59

shadow-cljs includes the same functionality as figwheel

Brian Abbott19:01:27

Okay, good to know

Brian Abbott19:01:38

when would one choose to use one over the other?

dpsutton19:01:57

honestly, i wouldn't choose figwheel at all these days. shadow is too good

☝️ 4
dpsutton19:01:30

and provides a killer feature in that @thheller does all the work to let you use npm deps as easily as possible in cljs

☝️ 4
Brian Abbott19:01:03

Okay, cool - I dont have a web or clojure background but, coming up to speed fast and, we are eval/re-eval’ing our dev/test/debug/profiling stack. We currently use FigWheel and, maybe we will have to look into making the move over to Shadow.

dpsutton19:01:34

if you have been wanting to be able to use proper npm deps rather than cljsjs versions its highly recommended. Also, Bruce just isn't working on figwheel any longer whereas @thheller is incredibly responsive and forward thinking.

☝️ 4
kanwei19:01:33

The required namespace "goog.date.relative.getPastDateString" is not available, it was required by xxx

kanwei19:01:47

getting that error when I

(:import [goog.date.relative getPastDateString])

kanwei19:01:54

any idea why that would be not found?

thheller19:01:22

@kanwei because its a function not a namespace most likely

thheller19:01:50

(:require [goog.date.relative :as rel]) (rel/getPastDateString ...)?

kanwei19:01:32

ya that works thanx 🙂