{}
๋ฅผ ํตํด ์ ๊ทผ ํ ์ ์๋ค.key
ํ๋กํผํฐ๋ฅผ ์ถ๊ฐํ๋ ๊ฒ์ ๊ฐ๋ ฅํ ๊ถ์ฅํ๋ค.)
```jsx
/**
jsx
/**); } function App(){ return (
);
}
jsx
/**
); } ```
import React from 'react';
import './App.css';
// ์คํ์ผ ๊ฐ์ฒด ์ ์
const divStyle = {
color: 'blue',
backgroundColor: 'lightgrey'
};
// App ์ปดํฌ๋ํธ ์ ์
function App() {
return (
<div className="App">
<div style={divStyle}>Styled element</div>
</div>
);
}
/* styles.css */
.container {
background-color: lightblue;
padding: 20px;
}
// App.js
import React from 'react';
import './styles.css';
function App() {
return <div className="container">Hello, World!</div>;
}
/* App.module.css */
.container {
background-color: lightblue;
padding: 20px;
}
// App.js
import React from 'react';
import styles from './App.module.css';
function App() {
return <div className={styles.container}>Hello, World!</div>;
}
// You can write code like this
function ChildComponent(props) {
const handleButtonClick = typeof props?.onClick == 'function' ? props?.onClick : () => {
alert("Button clicked!");
};
// ์ผํญ ์ฐ์ฐ์ ์ฌ์ฉ(Using state?A:B)
return (
<div>
ChildComponent<br/>
<button onClick={handleButtonClick}>ํด๋ฆญํ์ธ์</button>
</div>
);
}
function App(){
return (
<div>
<ChildComponent />
<ChildComponent onClick={() => {
alert("Custom onClick!");
}} />
</div>
);
}