export default function Button() {
const style = {
backgroundColor: 'skyblue',
border: 'none',
borderRadius: '10px',
padding: '5px 15px',
color: 'white',
fontSize: '20px'
}
return (
<>
<button type="button" style={style}>버튼</button>
</>
)
};

import style from './style.module.css';
export default function Button() {
return (
<>
<button type="button" className={style.button_style}>버튼</button>
</>
)
};
.button_style {
background-color: coral;
border: none;
border-radius: 10px;
padding: 5px 15px;
color: black;
font-size: 20px;
font-weight: bold;
}

import { useState } from 'react';
import style from './style.module.css';
import White from './White';
import Dark from './Dark';
export default function Button() {
let [state, setState] = useState(true);
if (state) {
return (
<>
<White />
<button onClick={() => {
if (state) setState(false);
else setState(true);
}} className={style.button_style} type="button" >버튼</button>
</>
)
} else {
return (
<>
<Dark />
<button onClick={() => {
if (state) setState(false);
else setState(true);
}} className={style.button_style} type="button" >버튼</button>
</>
)
}
};

import { useState } from 'react';
import style from './style.module.css';
import White from './White';
import Dark from './Dark';
export default function Button() {
let [state, setState] = useState(true);
return (
state ?
<>
<White />
<button onClick={() => {
if (state) setState(false);
else setState(true);
}} className={style.button_style} type="button" >버튼</button>
</> :
<>
<Dark />
<button onClick={() => {
if (state) setState(false);
else setState(true);
}} className={style.button_style} type="button" >버튼</button>
</>
)
};

import Login from './Login';
export default function Button() {
let isLogin = null;
return isLogin ?? <Login />
};
export default function Login() {
const style = {
width: '300px',
background: 'coral',
color: 'black',
textAlign: 'center'
}
return (
<>
<h1 style={style}>Login 상태</h1>
</>
)
}

||는 첫번째 Truthy 값을 반환
??는 첫번째 정의된 값을 반환
// ex)
let speed = 0;
console.log(speed || 150); // 150
console.log(speed ?? 150); // 0