Fork me on GitHub
#shadow-cljs
<
2024-03-31
>
James Pratt13:03:36

beginner question here, have been trying to figure this out for quite some time. For some reason https://github.com/jamiepratt/fulcro-barebones/blob/main/src/app/client.cljs#L8 I get nil. Requiring useWaverSurfer returns the object I would expect. Has someone got some further suggestions for how I can hunt down why this is happening?

James Pratt13:03:04

here is the export of the component in question from the npm package: https://github.com/katspaugh/wavesurfer-react/blob/main/src/index.tsx#L193

James Pratt13:03:12

my code compiles OK and there are no error messages or warnings until the code tries to create a WaveSurferPlayer component: Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

ghaskins13:03:57

Have you worked through the scenarios here: https://shadow-cljs.github.io/docs/UsersGuide.html#js-deps

👀 1
ghaskins13:03:06

When I am unsure, I put the resulting symbol in a js/console.log and that usually clears up what is going on

🙌 1
James Pratt13:03:59

if exported with default then do we require it differently?

ghaskins13:03:18

I’m guessing the first example applies to you

ghaskins13:03:39

The one using module-name$default

James Pratt13:03:07

success

👍 1
James Pratt13:03:59

I required as so : ["@wavesurfer/react" :default WavesurferPlayer]

James Pratt13:03:24

But but ["@wavesurfer/react$default" :as WavesurferPlayer] works too

ghaskins13:03:24

I’m just a user myself, so I don’t understand the difference, but glad it’s sorted

ghaskins13:03:02

I keep that section of the doc handy, though. Use it all the time

1
James Pratt13:03:07

thanks so much for your help @U13AR6ME1

👍 1
James Pratt13:03:37

what confused me is how similar a default import looks to a named import in js! see usage examples here for the component. https://github.com/katspaugh/wavesurfer-react/tree/main

James Pratt13:03:59

import WavesurferPlayer from '@wavesurfer/react'