Protected
attrsProtected
commitProtected
deleteProtected
diffVChildrenProtected
handleProtected
keyOptional
index: numberProtected
patchProtected
propsProtected
removeProtected
setProtected
updateProtected
vOptional
childrenOptional
isOptional
keyOptional
namespaceOptional
nodeOptional
parentOptional
propsOptional
refOptional
selectorOptional
styleOptional
tagOptional
textStatic
attrsStatic
propsProtected
generateStatic
fromDOMStatic
isOptional
key: IndexKeyOptional
key: IndexKeyOptional
key: IndexKeyA light-weight DOM Renderer supports Web components standard & TypeScript language.
+ + + +import { DOMRenderer } from 'dom-renderer';
const newVNode = new DOMRenderer().patch(
{
tagName: 'body',
node: document.body
},
{
tagName: 'body',
children: [
{
tagName: 'a',
props: { href: 'https://idea2.app/' },
style: { color: 'red' },
children: [{ text: 'idea2app' }]
}
]
}
);
console.log(newVNode);
+
+
+tsconfig.json
{
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "dom-renderer"
}
}
+
+
+index.tsx
import { DOMRenderer } from 'dom-renderer';
const newVNode = new DOMRenderer().render(
<a href="https://idea2.app/" style={{ color: 'red' }}>
idea2app
</a>
);
console.log(newVNode);
+
+
+view.tsx
import { DOMRenderer } from 'dom-renderer';
const renderer = new DOMRenderer();
const Hello = () => <h1>Hello, JSX SSR!</h1>;
export const generateStream = () => renderer.renderToReadableStream(<Hello />);
+
+
+index.ts
import { Readable } from 'stream';
import { createServer } from 'http';
import 'dom-renderer/polyfill';
import { generateStream } from './view';
createServer((request, response) => {
const stream = generateStream();
Readable.fromWeb(stream).pipe(response);
}).listen(8080);
+
+
+
See
https://babeljs.io/docs/babel-plugin-transform-react-jsx#react-automatic-runtime-1
+