This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-04-24
Channels
- # announcements (8)
- # babashka (16)
- # beginners (18)
- # biff (4)
- # calva (18)
- # clj-kondo (20)
- # clojure (24)
- # clojure-brasil (1)
- # clojure-europe (13)
- # clojure-nl (1)
- # clojure-norway (35)
- # clojure-uk (3)
- # clojurescript (16)
- # core-async (50)
- # cursive (5)
- # data-science (5)
- # datalevin (5)
- # datomic (69)
- # dev-tooling (18)
- # fulcro (3)
- # gratitude (1)
- # honeysql (5)
- # hyperfiddle (4)
- # jackdaw (2)
- # jobs-discuss (24)
- # lambdaisland (7)
- # lsp (16)
- # malli (5)
- # off-topic (65)
- # overtone (16)
- # pathom (28)
- # portal (3)
- # re-frame (24)
- # releases (1)
- # shadow-cljs (101)
Bit of a newbie here... how can I configure shadow-cljs to attach a custom header like Document-Policy: js-profiling
for local development?
Trying to get some browser profiling with Sentry setup.
To potentially save you a lot of headache - don't profile development apps. It's almost completely pointless. Profile production builds with pseudo-names enabled in shadow-cljs.
very good point, but my goal is less to profile development builds and more to get it actually working so we can flip it on in production 🙂
There's a great potential to stumble upon all sorts of issues due to the discrepancies between dev and prod builds.
Your server seems to be different - ideally, it should be the same. The fact that you set the right header with shadow-cljs doesn't guarantee in any way that the prod server also sets it in the correct way.
The dev build is split into a bazillion of files, whereas the prod build is usually just a single file (or a few, if you have module splitting).
Perhaps there are other differences.
If you aren't persuaded and want to proceed with the dev server that shadow-cljs provides, the https://shadow-cljs.github.io/docs/UsersGuide.html#dev-http way to do it would be to pass a :push-state/headers
option. Or a :handler
option if you need more control.
Yeah I hear you, I have ZERO intention of actually doing this locally, I just want to see the profiler run so I know what I really do need to do on the serverside in production. 🙂
But you could be right, I suppose I could just deploy straight to staging instead
In similar cases, I just launch the prod config locally. No clue whether it's possible with your setup.
Hi i just try to make carousel using react-material-ui-carousel with reagent and material ui.... but there is a problem
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.
Check the render method of `fe_learning.components.carousel.CarouselComponent`.
cmp@http://localhost:8280/js/compiled/cljs-runtime/reagent.impl.component.js:499:43
div
shadow$provide.module$node_modules$$emotion$react$dist$emotion_element_48d2c2e4_cjs_dev/exports.withEmotionCache/<@http://localhost:8280/js/compiled/cljs-runtime/module$node_modules$$emotion$react$dist$emotion_element_48d2c2e4_cjs_dev.js:4:160
shadow$provide.module$node_modules$$mui$system$createBox/exports.default/<@http://localhost:8280/js/compiled/cljs-runtime/module$node_modules$$mui$system$createBox.js:3:255
div
shadow$provide.module$node_modules$$emotion$react$dist$emotion_element_48d2c2e4_cjs_dev/exports.withEmotionCache/<@http://localhost:8280/js/compiled/cljs-runtime/module$node_modules$$emotion$react$dist$emotion_element_48d2c2e4_cjs_dev.js:4:160
shadow$provide.module$node_modules$$mui$system$createBox/exports.default/<@http://localhost:8280/js/compiled/cljs-runtime/module$node_modules$$mui$system$createBox.js:3:255
div
shadow$provide.module$node_modules$$emotion$react$dist$emotion_element_48d2c2e4_cjs_dev/exports.withEmotionCache/<@http://localhost:8280/js/compiled/cljs-runtime/module$node_modules$$emotion$react$dist$emotion_element_48d2c2e4_cjs_dev.js:4:160
shadow$provide.module$node_modules$$mui$system$createBox/exports.default/<@http://localhost:8280/js/compiled/cljs-runtime/module$node_modules$$mui$system$createBox.js:3:255
cmp@http://localhost:8280/js/compiled/cljs-runtime/reagent.impl.component.js:499:43
cmp@http://localhost:8280/js/compiled/cljs-runtime/reagent.impl.component.js:499:43
i dont know what is wrong but this is my code
(ns fe-learning.components.carousel
(:require [reagent.core :as r]
[re-frame.core :as rf]
["@mui/material" :as mui]
["react-material-ui-carousel" :as carousel]))
(defn CarouselComponent []
(let [items [{:img "image1.jpg" :title "Item 1"}
{:img "image2.jpg" :title "Item 2"}
{:img "image3.jpg" :title "Item 3"}]]
[:> carousel/Carousel
{:animation "slide"
:autoplay true
:indicators false
:timeout 3000
:navButtonsAlwaysVisible true
:infiniteLoop true}
(for [item items]
[:div
[:img {:src (get item :img)
:alt (get item :title)}]])]))
is there anything wrong with my code?This is the important part:
> React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined.
And this is an important suggestion from that warning:
> you might have mixed up default and named imports.
Chances are, carousel/Carousel
in your code is undefined
and you need to import carousel
in some other way.
Shadow-cljs has a good section on the topic in its docs.
it took me a while to understand but is the way import carousel wrong? i think i have to read shadow cljs docs 🥲
Yeah. To confirm, just add (js/console.log carousel)
at the top of the ns (but under the ns
form itself, of course) and see what it prints.
If it prints an object that has a default
field, then you probably need to use ["react-material-ui-carousel$default" :as Carousel]
.
If it prints some weird object, then it's probably just ["react-material-ui-carousel" :as Carousel]
.
just find out that i can print import 🤯 print same object with or with out "" when import react-material-ui-carousel
Well, there you go - there's that default
field. Try the first option I suggested above. Of course, it implies that you use it as Carousel
instead of carousel/Carousel
.
FWIW this is the relevant doc section, showing a bunch of examples of how to translate js import
to CLJS. https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages