stereobooster / react-snap

👻 Zero-configuration framework-agnostic static prerendering for SPAs
MIT License
5.04k stars 391 forks source link

"Basic usage with Preact" docs should be updated #423

Open indifferentghost opened 4 years ago

indifferentghost commented 4 years ago

Feature Request

Is your feature request related to a problem? Please describe.

The Preact Section in the readme, as they are out of date. Preact v10 has a proper hydrate method now. PR: preactjs/preact#1802.

Describe the solution you'd like Update the README essentially to what the React section looks like:

import { h, render, hydrate } from 'preact';
import { App } from './app';

const rootElement = document.getElementById('root');
if (rootElement.hasChildNodes()) {
  hydrate(h(App), rootElement);
} else {
  render(h(App), rootElement);
}

Teachability, Documentation, Adoption, Migration Strategy Document change.

indifferentghost commented 4 years ago

A little bit of background:

I'm working with an unusual stack (mostly for fun) that includes htm, preact, and react-snap. The previous documentation through me for quite a loop since htm allows you to return sibling components:

htm`
<div id="one" />
<div id="two" />
`;

which renders to two different divs in the dom

The previous method: preact.render(<App />, rootElement, rootElement.firstElementChild); would replace <div id="one" /> when it updated, but add an additional <div id="two" />

iMakedonsky commented 3 years ago

+1 to that