Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: create-react-class could not find the React object. #169

Open
neilyio opened this issue Nov 19, 2020 · 0 comments
Open

Error: create-react-class could not find the React object. #169

neilyio opened this issue Nov 19, 2020 · 0 comments

Comments

@neilyio
Copy link

neilyio commented Nov 19, 2020

I have a very minimal project using figwheel-main and devcards. I'm using npm versions of react and react-dom, as well as the Figwheel {:auto-bundle :webpack} option.

Simply loading my single main.cljs file with a (:require [devcards.core]) results in the following error in the browser:

Error: create-react-class could not find the React object. If you are using script tags, make sure that React is being loaded before create-react-class.

Here's the entire main.cljs:

(ns main.core
  (:require
   [devcards.core]))

Here's my entire deps.edn:

{:deps {org.clojure/clojure       {:mvn/version "RELEASE"}
        org.clojure/clojurescript {:mvn/version "RELEASE"}
        com.bhauman/figwheel-main {:mvn/version "RELEASE"}
        devcards                  {:mvn/version "RELEASE"}
        reagent                   {:mvn/version "RELEASE"
                                   :exclusions [cljsjs/react cljsjs/react-dom]}}

 ;; Run the devcards build with clojure -A:fig --build devcards --repl
 :aliases {:fig {:main-opts ["-m" "figwheel.main"]}}

 :paths   ["src" "cljs-src" "target" "resources"]}

Here's my entire build file, devcards.cljs.edn:

^{:auto-bundle :webpack}
{:main main.core
 :devcards true}

I don't get the error unless I :require devcards.core. This main.cljs, with a regular reagent.dom/render, works fine:

(ns main.core
  (:require [reagent.dom :as rd]))

(defn component []
  [:h1 "hello world!"])

(defn mount []
  (rd/render [component] (.getElementById js/document "main-app-area")))

(defonce init (do (mount) true))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant