<></>(fragment태그)
- 함수 밑에
export default 함수명>
=> 모듈은 기본 내보내기 딱 하나만 가능- 함수명 앞에
export입력
import 함수명 from "경로";=> export default로 기본 내보내기를 한 경우
import {함수명} from "경로";=> 함수명 앞에 export를 사용한 경우
=> 두 개 이상의 함수를 가져오는 경우 ,을 사용하여 함수명 입력
ex) import {Text, Text2} from "./components/Text";

index.js
const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);
=> 아무것도 건들지 않았음
App.js
import { Text, Text2 } from "./components/Text";
function App() {
return (
<>
<div>1번</div>
<div>2번</div>
<Text />
<Text2 />
{/* => 컴포넌트 */}
</>
);
}
export default App;
Text.js
export const Text = () => {
return (
<>
<h1>컴포넌트는 무엇일까요?</h1>
<h1>컴포넌트는 무엇일까요?</h1>
<h1>컴포넌트는 무엇일까요?</h1>
<h1>컴포넌트는 무엇일까요?</h1>
<h1>컴포넌트는 무엇일까요?</h1>
<h1>컴포넌트는 무엇일까요?</h1>
</>
);
};
export const Text2 = () => {
return <div>두 번째 텍스트</div>;
};