<!DOCTYPE html>
<html lang="ko">
<body>
<div id="root"></div>
</body>
<script src="https://unpkg.com/react@17.0.2/umd/react.production.min.js"></script>
<script src="https://unpkg.com/react-dom@17.0.2/umd/react-dom.production.min.js"></script>
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<script type="text/babel">
const root = document.getElementById("root");
function Btn(props) {
console.log(props);
return <button style={{
backgroundColor: "tomato",
color: "white",
padding: "10px 20px",
radius: "999px",
border: "none",
borderRadius: "999px"
}}>{props.banana}</button>
}
function App() {
return (
<div>
<Btn banana="Save Changes" />
// Btn({banana:"save changes})와 동일함
<Btn banana="Continue" />
</div>
);
}
ReactDOM.render(<App />, root)
</script>
</html>
<Btn banana="Save Changes" x="false"/>
이렇게 넣어주면...
function Btn({banana}) {
return <button style={{
backgroundColor: "tomato",
color: "white",
padding: "10px 20px",
radius: "999px",
border: "none",
borderRadius: "999px"
}}>{banana}</button>
}
function Btn({banana, big}) {
return <button style={{
backgroundColor: "tomato",
color: "white",
padding: "10px 20px",
radius: "999px",
border: "none",
borderRadius: "999px",
fontSize: big ? 18 : 16
}}>{banana}</button>
}
function App() {
return (
<div>
<Btn banana="Save Changes" big={true}/>
<Btn banana="Continue" />
</div>
);
}