dyo / dyo

Dyo is a JavaScript library for building user interfaces.

Home Page:https://dyo.js.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Deep Suspense and Server Side Rendering

Zolmeister opened this issue · comments

The following works in the browser, but not node.js

{h, useResource, Suspense, render} = require 'dyo/server/dist/dyo.umd.js'

A = ->
  useResource ->
    Promise.resolve null
  h 'div', 'x'

B = ->
  # works if uncommented
  # h Suspense,
  h 'div', A

C = ->
  h Suspense, B

stringify = (tree) ->
  class Writable
    constructor: ->
      @innerHTML = ''
      @end = @write
    write: (value) =>
      @innerHTML += value

  {innerHTML} = await render tree, new Writable()
  return innerHTML

console.log await stringify C

Expected

<div><div>x</div></div>

Received

TypeError: Cannot read property 'identity' of undefined

From what I can tell, it's trying to mutate the DOM (Interface), which doesn't exist in node.