This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-09-11
Channels
- # beginners (70)
- # clojure (34)
- # clojure-europe (1)
- # clojure-nl (2)
- # clojure-uk (3)
- # clojurescript (140)
- # cursive (6)
- # data-science (1)
- # emacs (8)
- # exercism (1)
- # fulcro (2)
- # gratitude (1)
- # helix (4)
- # hyperfiddle (5)
- # meander (3)
- # missionary (2)
- # pathom (4)
- # polylith (17)
- # reagent (7)
- # reitit (6)
- # reveal (2)
- # shadow-cljs (3)
- # uncomplicate (6)
Hi, how would you reference local images (png) in Reagent? What's the equivalent of import RandomImage from "../images/random_image.png";
?
I tried using the (rc/inline "../images/random_images.png")
from https://clojureverse.org/t/using-none-code-resources-in-cljs-builds/3745 referenced in a previous post about SVGs but that doesn't seem to work
What do you expect RandomImage
to contain? A data URL? A regular URL where the PNG is copied into the output directory? Something else?
I'm pretty sure it'd be a string? Not too certain about React default behaviour when it comes to importing images
From https://create-react-app.dev/docs/adding-images-fonts-and-files/: > You can `import` a file right in a JavaScript module. This tells webpack to include that file in the bundle. Unlike CSS imports, importing a file gives you a string value. This value is the final path you can reference in your code, e.g. as the `src` attribute of an image or the `href` of a link to a PDF. > To reduce the number of requests to the server, importing images that are less than 10,000 bytes returns a https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs instead of a path.