Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/johnsi15/example-react-jsx-esm


https://github.com/johnsi15/example-react-jsx-esm

Last synced: 4 days ago
JSON representation

Awesome Lists containing this project

README

        

# Example react ESM with esm.sh

The script has to be of type module ` `

# [CDN](https://esm.sh/)

# [ESM](https://lenguajejs.com/javascript/modulos/que-es-esm/)

```javascript
import React from "https://esm.sh/[email protected]"
import ReactDOM from "https://esm.sh/[email protected]/client"

const appElement = document.getElementById('app')

const root = ReactDOM.createRoot(appElement)

const el = React.createElement("section",{class:"container"},React.createElement("h3",null,"Hello world"));

root.render(el)

```

```javascript
// main.js
import React from 'https://esm.sh/[email protected]'
import ReactDOM from 'https://esm.sh/[email protected]/client'

import App from './App.js'

const el = React.createElement(App, null)

ReactDOM.createRoot(document.getElementById('app')).render(el)

```

```javascript
// App.js
import React from 'https://esm.sh/[email protected]'

function HolaMundo() {
return React.createElement(
'div',
{ className: 'hola' },
React.createElement('h3', null, 'Hola mundo')
)
}

export default HolaMundo

```