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

Reagent video 20 Firebase Setup with Firebase 9.23.0 needs clj->js for config #25

Open
kentbull opened this issue Jul 1, 2023 · 2 comments

Comments

@kentbull
Copy link

kentbull commented Jul 1, 2023

Using the latest, as of today, 9.23.0 version of Firebase with this course requires a slight change to wrap the config object in the clj->js function so that the firebase/initializeApp function can recognize the configuration object as a proper JSON object.

(ns giggin.fb.init
  (:require ["firebase/app" :as firebase]
            ["firebase/database"]
            ["firebase/auth"]))

(defn firebase-init
  []
  (let [config (clj->js {:apiKey "myapikey"
                         :authDomain "mydomain.firebaseapp.com"
                         :projectId "mydomain"
                         :storageBucket "mydomain.appspot.com"
                         :messagingSenderId "1234123412341234"
                         :appId "1:123412341234:web:1234123c41234c123c"
                         :measurementId "G-SD78DF8DDF8"})
        app (firebase/initializeApp config)]))
@jacekschae
Copy link
Owner

There are two ways to convert ClojureScript maps to JavaScript objects. You could use clj->js which is one way and a bit more heavier (it will also evaluate any code you have in the CLJS map and then there is #js {} which converts the thing without evaluating; when you have static properties, as in this example, it's advisable to use #js {} hope that helps.

@kentbull
Copy link
Author

kentbull commented Jul 2, 2023

Those two ways make sense. What was a problem for me was the video showing use of the config in firebase/initializeApp without showing Clj->js and thus was stuck on errors for a while.

the next video shows that, though first timers would be tripped up.

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

2 participants