Skip to content

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

@neilyio

Description

@neilyio

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))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions