Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/deseteral/stunning-jsx-renderer

Why do I keep putting this kind of stuff on GitHub...
https://github.com/deseteral/stunning-jsx-renderer

amazing deal-breaker game-changer shocking stunning wonderful

Last synced: 21 days ago
JSON representation

Why do I keep putting this kind of stuff on GitHub...

Awesome Lists containing this project

README

        

# stunning-jsx-renderer

🎈 ☃️ 🎈 ⚡ 🎈 ️🍾 🎈 🗿 🎈

> Honestly it's not that stunning.
>
> Acutally it's very simple.
>
> And probably incorrect in some cases.

Just don't use it for anything serious and you will be fine.

## What?
You put in JSX and out comes HTML string.

```javascript
/** @jsx createElement */
const { renderToString, createElement } = require('./src/server-side');

const html = renderToString(

This is amazing!



);

console.log(html); // '

This is amazing!
'
```

There's also client-side version:

```javascript
/** @jsx createElement */

domRender(

This is amazing!

document.body
);

console.log(document.body.innerHTML); // '

This is amazing!
'
```

## Why?
I don't know, just wanted to try to figure out how JSX and [ReactDOMServer#RenderToStaticMarkup](https://reactjs.org/docs/react-dom-server.html#rendertostaticmarkup) and [ReactDOM#render](https://reactjs.org/docs/react-dom.html#render) works I guess?