Skip to content

Instantly share code, notes, and snippets.

@laniehei
Last active July 6, 2018 03:23
Show Gist options
  • Save laniehei/d9a4496e94aa8f7aea0d0a19151d6a43 to your computer and use it in GitHub Desktop.
Save laniehei/d9a4496e94aa8f7aea0d0a19151d6a43 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div id="app"></div>
<script src="node_modules/react/dist/react.js"></script>
<script src="node_modules/react-dom/dist/react-dom.js"></script>
<script>
const ce = React.createElement
const MyTitle = function (props) {
return (
ce('div', null,
ce('h1', { style: { color: props.color } }, props.title)
)
)
}
const MyFirstComponent = function () {
return ce('div', { id: 'my-first-component' },
[ce(MyTitle, { title: 'Game of Thrones', color: 'YellowGreen' }),
ce(MyTitle, { title: 'Stranger Things', color: 'GreenYellow' }),
ce(MyTitle, { title: 'Rick and Morty', color: 'LimeGreen' }),
ce(MyTitle, { title: 'Silicon Valley', color: 'peru' })]
)
}
ReactDOM.render(
ce(MyFirstComponent),
document.getElementById('app')
)
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment