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

TypeError when using function components with r/create-class with dom.server/render-to-string #581

Open
p-himik opened this issue Oct 21, 2022 · 0 comments
Labels

Comments

@p-himik
Copy link

p-himik commented Oct 21, 2022

A weird combination, but seems like nextjournal/clerk would benefit from it. The initial discussion on Slack.

A minimal reproducible example:

(ns app.core
  (:require [reagent.dom.server :as dom.server]
            [reagent.core :as r]))

(r/set-default-compiler! (r/create-compiler {:function-components true}))

(defn root []
  (r/create-class {:reagent-render (fn [] [:span])})
  ;[:span]
  )

(js/console.log (dom.server/render-to-string [root]))

Uncommenting that [:span] makes it work. Rendering to a regular DOM makes it work. Not using function components makes it work.

mk added a commit to nextjournal/clerk that referenced this issue Nov 1, 2022
To work around reagent-project/reagent#581. Enable the functional reagent compiler also for server-side-rendering fixing an error that occurred previously when trying to render a component with hooks.

Co-authored-by: Martin Kavalar <[email protected]>
@Deraen Deraen added the bug label Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants