bhauman / bhauman/devcards

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

Open
#169 0 comments 5 reactions 0 assignees View on GitHub
Dominant language
Clojure
Stars
1.5k
Forks
106
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.