Comments (3)
Whoops, I've debugged this one. The solution was simply to add the proper relative file name in the index.html
. But then arises a different problem with the release compiled javascript
and it throws the following error in the browser.
TypeError: snake.core.init is not a function
Perhaps, this is another quick fix but nothing strikes my mind as of now.
from learn-reagent-course-files.
Seems like you are exporting main
and not init
defn init []
;; init is called ONCE when the page loads
;; this is called in the index.html and must be exported
;; so it is available even in :advanced release builds
;(js/console.log "init")
;; Resize canvas object
(resize-canvas)
;; Remove all listen events
(events/removeAll js/document)
;; Register event listener `on-keydown` event
(events/listen js/document goog.events.EventType.KEYDOWN on-keydown)
;; Start the game loop
(game-loop))
(defn ^:export main
[]
(r/render
[app]
(.getElementById js/document "app")))
When you don't add ^:export
before init
, or any function name that you want to access from html file it will be shortened by the google closure compiler and might end up as - let's say c
- in this way it cannot find the init
function. Therefore the error.
You can also change the way you setup shadow-cljs and don't worry about the ^:export
- check out learn re-frame setup In this way you have init-fn
which takes care of ^:export
and the only thing you need to add to index.html is the a script name.
Hope that helps, if you would have any further questions let me know.
from learn-reagent-course-files.
Ahh, yes - that's true! I'll be for sure covering up the re-frame tutorial today itself. Thanks @jacekschae , your course has been one of the best learning experiences for people learning ClojureScript
👍
from learn-reagent-course-files.
Related Issues (20)
- `gigs` returns a function in `14 Gig Editor` but it was never added HOT 2
- Fabulous Course - Comment section? HOT 1
- Can't interact with shadow.cljs because Java cannot find the shadow.cljs.devtools.api/nrepl-select class
- The tag <tag> is unrecognized in this browser. If you meant to render a React component, start its name with an uppercase letter. HOT 3
- Can't install npm package firebase version 4.13.1 HOT 5
- Cannot invoke Object.getClass() because target is null HOT 5
- "for" over orders in orders.cljs HOT 6
- Add license to package.json to eliminate warning. HOT 1
- How to setup CORS settings HOT 3
- Modified code for Firebase 9: Lessons 22 & 24 HOT 3
- Calva and Shadow cljs HOT 3
- Bug: Learn Reagent Pro: upsert-gig on the gigs.cljs HOT 1
- Reagent video 20 Firebase Setup with Firebase 9.23.0 needs clj->js for config HOT 2
- Reagent 21 Firebase Database: regenerator-runtime/runtime required in order to use the realtime database. HOT 1
- upsert-gig inserts nil id HOT 4
- Bug in the add new gig HOT 2
- nrepl Error Spacemacs HOT 2
- use a more recent shadow-cljs version HOT 1
- Runtime error: "A component is changing a controlled input of type checkbox to be uncontrolled." HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from learn-reagent-course-files.