client.js 479 B

123456789101112131415161718192021
  1. const { render, hydrate, unmountComponentAtNode } = require('preact/compat');
  2. function createRoot(container) {
  3. return {
  4. // eslint-disable-next-line
  5. render: function (children) {
  6. render(children, container);
  7. },
  8. // eslint-disable-next-line
  9. unmount: function () {
  10. unmountComponentAtNode(container);
  11. }
  12. };
  13. }
  14. exports.createRoot = createRoot;
  15. exports.hydrateRoot = function (container, children) {
  16. hydrate(children, container);
  17. return createRoot(container);
  18. };