핑구식코딩 2020. 4. 2. 21:19

React 커맨드 사용

1. ReactDOM.render(displayResult, root)

displayResult : 나타낼 결과

root : 나타낼 위치(id)

 

React.createElement(tag, attribute, content)

tag: html 태그(h1,a태그 등)

state: attribute: 속성(a태그 href)

content: 표시할 컨텐츠("hello react")

 

<html>
​
<head>
    <script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
    <script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
    
</head>
​
<div id="root">
    
</div>
​
​
<script type="text/javascript">
​
const displayResult = React.createElement(
    "h1",
    null,
    "Hello React !!"
)
​
ReactDOM.render(displayResult, root);
</script>
​
</html>


출처: https://kim6394.tistory.com/111?category=681336 [Gyoogle (규글)]