[React] Component File ๋ถ„๋ฆฌ

2021. 9. 26. 08:00ใ†Front-End ์ž‘์—…์‹ค/Vue.js

728x90
๋ฐ˜์‘ํ˜•

 

๐Ÿ“Œ ๊ฐœ๋…


 

๋งŒ์•ฝ ํ•˜๋‚˜์˜ ํŒŒ์ผ์•ˆ์— ์ฒœ ๊ฐœ๊ฐ€ ๋„˜๋Š” ์ปดํฌ๋„ŒํŠธ๋“ค์ด ์žˆ๋‹ค๋ฉด ์–ผ๋งˆ๋‚˜ ๋ณต์žกํ• ๊นŒ์š”?

App.js์— ์ปดํฌ๋„ŒํŠธ๊ฐ€ ์žˆ๋‹ค๋ณด๋‹ˆ ๋‹ค๋ฅธ ํŒŒ์ผ๋“ค์€ ์ ‘๊ทผํ•ด์„œ ์‚ฌ์šฉํ•˜๊ธฐ๊ฐ€ ์–ด๋ ค์šด ๊ฒƒ์ด์—์š”.

์ด๋ฅผ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด src์— ํŠน์ • ๋””๋ ‰ํ„ฐ๋ฆฌ๋ฅผ ๋งŒ๋“ค๊ณ , ๊ทธ ์•ˆ์— ๊ฐ๊ฐ์˜ ์ปดํฌ๋„ŒํŠธ ๋ณ„๋กœ ๊ฐ๊ฐ ํŒŒ์ผ๋กœ ๋”ฐ๋กœ ๋งŒ๋“œ๋Š” ๊ฒƒ์ด ๋ฐฉ๋ฒ•์ด๋ž๋‹ˆ๋‹ค.

๋จผ์ € ๊ฐ Component๋ฅผ ์ง€์ •ํ•œ jsํŒŒ์ผ ์•ˆ์— ๋„ฃ๋Š”๋ฐ, React import๋ฅผ ์œ„ํ•ด ์ตœ์ƒ๋‹จ์— ์•„๋ž˜์™€ ๊ฐ™์ด ์ ์–ด์ค˜์•ผ ํ•˜๋Š” ๊ฒƒ์ด์—์š”.

import React, { Component } from "react";



๊ทธ๋Ÿฐ ๋’ค ๋งจ ๋งˆ์ง€๋ง‰์— ๋‹ค๋ฅธ ํŒŒ์ผ๋“ค๋„ ํ•ด๋‹น ์ปดํฌ๋„ŒํŠธ๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•˜๊ธฐ ์œ„์•  ๋งจ ๋งˆ์ง€๋ง‰์— ์•„๋ž˜ ์ฝ”๋“œ๋ฅผ ๋„ฃ์–ด์ค˜์•ผ ํ•˜๋Š” ๊ฒƒ์ด์—์š”.

export default [์ปดํฌ๋„ŒํŠธ ์ด๋ฆ„];
๋ฐ˜์‘ํ˜•




๊ทธ๋ ‡๊ฒŒ ํ•œ ๋’ค ์ด ์ปดํฌ๋„ŒํŠธ๋ฅผ ์‚ฌ์šฉํ•  ๊ณณ ์ƒ๋‹จ์— ์•„๋ž˜ ์ฝ”๋“œ๋ฅผ ์ถ”๊ฐ€ํ•˜์—ฌ ์ฃผ๋ฉด ๋œ๋‹ต๋‹ˆ๋‹ค.

import [์ปดํฌ๋„ŒํŠธ ์ด๋ฆ„] from "./[์ปดํฌ๋„ŒํŠธ๊ฐ€ ์žˆ๋Š” ๋””๋ ‰ํ„ฐ๋ฆฌ ์ด๋ฆ„ / ์ปดํฌ๋„ŒํŠธ ์ด๋ฆ„];

 

 

 

 


 

์ฃผ๋‹ˆํ•˜๋ž‘์˜ ๊ธ€์ด ๋งˆ์Œ์— ๋“œ์…จ๋‚˜์š”? ๊ตฌ๋…๊ณผ ๊ณต๊ฐ! ๊ทธ๋ฆฌ๊ณ , ๋Œ“๊ธ€ ๊ทธ๋ฆฌ๊ณ  ๋ฐฉ๋ช…๋ก์€ ์ฃผ๋‹ˆํ•˜๋ž‘์—๊ฒŒ ๋งŽ์€ ํž˜์ด ๋ฉ๋‹ˆ๋‹ค

728x90
๋ฐ˜์‘ํ˜•

'Front-End ์ž‘์—…์‹ค > Vue.js' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

[React] State์™€ Props์˜ ์ฐจ์ด  (0) 2021.10.02
[React] State  (0) 2021.09.27
[React] Props  (0) 2021.09.25
[React] Component ๋งŒ๋“ค๊ธฐ  (0) 2021.09.24
[React] ์ฒ˜์Œ ์‹œ์ž‘ํ•˜๋Š” React  (0) 2021.09.16