clj-commons / cljss

Clojure Style Sheets — CSS-in-JS for ClojureScript
https://roman01la.github.io/cljss/
Eclipse Public License 1.0
454 stars 27 forks source link

cljss.reagent: React is not defined #65

Open vnctaing opened 3 years ago

vnctaing commented 3 years ago

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].

carina-akaia commented 3 years ago

I have the same problem.

rosenjcb commented 3 years ago

Same error here.

parlir commented 3 years ago

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 commented 3 years ago

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.