preact-render-to-string icon indicating copy to clipboard operation
preact-render-to-string copied to clipboard

`options._diff` not called for implicit Fragments

Open marvinhagemeister opened this issue 2 years ago • 2 comments

import { render, h,options, Fragment}  from "preact"
import renderToString from "preact-render-to-string"

const oldDiff = options.__b;
options.__b = (vnode) => {
  if (vnode.type === Fragment) {
    console.log(vnode.type === Fragment ? vnode.props:null)
  }
  if (oldDiff) oldDiff(vnode)
}

function App() {
  return <div>
    <h1>test</h1>
    {[
      <p key="1">1</p>,
      <p key="2">2</p>,
      <p key="3">3</p>,
    ]}
  </div>
}

const app = document.getElementById("app");
render(<App />, app)

console.log("=====")

// Fragments not visible in options._diff with RTS
renderToString(<App />);

marvinhagemeister avatar Sep 23 '23 09:09 marvinhagemeister