I'm trying to get JSBarcode to render in my ClojureScript website. Here is some…
- User
I'm trying to get JSBarcode to render in my ClojureScript website. Here is some associated code.
(ns ui.new (:require ["reactstrap" :as rs] ["jsbarcode" :as barcode] [cljs.pprint :refer [cl-format]] [clojure.string :as string] [goog.dom :as gdom] [goog.style :as gstyle] [reagent.core :as ra] [reagent.dom :as rdom] ["react-dom" :refer (createPortal)]))
(defn barcode-render [value] (let [barcode-element-id (str "barcode-" (random-uuid))] #(barcode (str "#" barcode-element-id) value {:format "CODE128" :lineColor "#000000" :width 2 :height 40 :displayValue true}) ;[:svg {:id barcode-element-id}] ))
(the page component namespace) (ns inventory.edit.component (:require [clojure.string :as string] [re-frame.core :as rf] [reagent.core :as ra] [ui.new :as new]))
(defn- scancode-section [scancode] [ui/row row-config [label-col {:class "col-md-3 col-sm-6 col-6 justify-content-end"} "Scanning Code"] [input-col {:class "col-md-3 col-sm-6 col-6 justify-content-end"} [text-input-field :scan-code]]] [new/barcode-render scancode] ) ... (defn general-section [] (let [current-instance-type @(rf/subscribe [:inventory-edit/instance-type]) new-instance-type @(rf/subscribe [:inventory-edit/new-instance-type]) price-by-margin? @(rf/subscribe [:inventory-edit/get-price-option-setting]) updates-disabled? @(rf/subscribe [:inventory-edit/updates-disabled?]) is-active? @(rf/subscribe [:inventory-edit/is-active?]) allow-changing-type? @(rf/subscribe [:inventory-edit/allow-changing-type?]) desirable-minimum @(rf/subscribe [:inventory-edit/desirable-minimum]) desirable-maximum @(rf/subscribe [:inventory-edit/desirable-maximum]) uom @(rf/subscribe [:inventory-edit/uom]) allow-changing-asset-account? @(rf/subscribe [:inventory-edit/allow-changing-asset-account?]) display-asset-account-code? @(rf/subscribe [:inventory-edit/display-asset-account-code?])]
... (page component) [:ui/container ... [:hr]
code[scancode-section 4567845678 ] ; test code... ]
I am currently getting this message: Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.
What do I need to do to complete this function to render barcodes?
- Assistant
- User
Unresolved var: rdom/find-dom-nodeclj-kondo(unresolved-var)
- Assistant
In ClojureScript with Reagent, the function to find a DOM node is provided by
reagent.dommodule. It looks like you are usingrdom/find-dom-nodewhich doesn't exist. Instead, you should use . This function when passed a component instance reference, will return the underlying DOM element.