Skip to content

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

@p-himik

Description

@p-himik

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions