cljss icon indicating copy to clipboard operation
cljss copied to clipboard

cljss.reagent: React is not defined

Open vnctaing opened this issue 4 years ago • 4 comments

Observed Behavior

Hello I'm using Luminus template for shadow-cljs, and I'm trying to use cljss.reagent

(ns tartataing.core
  (:require
   ...
   [cljss.reagent :refer-macros [defstyled]]
   ...)
  (:require-macros [cljss.core])
  (:import goog.History))

This produce these erros

app.js:1673 ReferenceError: React is not defined
    at G__54946 (core.cljs:23)
    at cmp.G__52675__delegate (core.cljs:129)
    at cmp.tartataing.core.Kikoo [as reagentRender] (core.cljs:119)
    at eval (component.cljs:108)
Error rendering component (in tartataing.core.Kikoo)
The above error occurred in the <tartataing.core.Kikoo> component:
    in tartataing.core.Kikoo (created by navbar)

Is there something I did wrong ?

Expected behavior

Being able to render red title [:h1].

vnctaing avatar Oct 18 '20 06:10 vnctaing

I have the same problem.

carina-akaia avatar Jan 08 '21 03:01 carina-akaia

Same error here.

rosenjcb avatar May 24 '21 05:05 rosenjcb

I encountered this as well it looks as though the macro eventually expands to a raw call of js/React

(require '[react :as React])
(set! (.. js/window -React) React)

was a quick fix hack in my case.

parlir avatar Jun 04 '21 18:06 parlir

It seems as though the macro should avoid expanding to js/React.createElement and instead expand to reagent.core/create-element which is a wrapper around Reacts createElement func.

parlir avatar Jun 04 '21 18:06 parlir