Import Export

import

// ./style/index.ts

import * from './background';
import * from './label';
// ./index.ts

import * as S from './style';

export default function Button() {

...

return (
    <S.Background>
        <Button/>
    </S.Background>
)}

import

//๊ธฐ๋ณธ
import Example from './Example.js';

//export ํ•  ๋•Œ default๊ฐ€ ์—†์œผ๋ฉด ์ค‘๊ด„ํ˜ธ๊ฐ€ ํ•„์ˆ˜
import {Example} from './Example.js';

import React, {Component} from 'react';

//node_modules์— ์„ค์น˜๋œ ๋ชจ๋“ˆ์„ ๋ถˆ๋Ÿฌ์˜ฌ ๋•Œ๋Š” ๊ฒฝ๋กœ ์ง€์ • ํ•„์š”์—†์Œ
import Example from 'Example';

//๋ชจ๋“ˆ ์ „์ฒด์˜ ์‚ฌ์ด๋“œ ์ดํŽ™ํŠธ๋งŒ ๊ฐ€์ ธ์˜จ๋‹ค๋Š”๋ฐ 
import './Example.js';

export

const coffee = function (i) {
   let sum = i + 2 
};

const example = 2;


export default coffee;
export {example};
export const foo = "HI";
import coffee.sum, {example, foo} from './example';

default๋ฅผ ์“ฐ๋ฉด ๊ธฐ๋ณธ์ ์œผ๋กœ ๋ณด๋‚ผ ๊ฒƒ์„ ์ •ํ•œ๋‹ค. ํŒŒ์ผ์—์„œ ํ•œ๋ฒˆ๋งŒ ์“ธ ์ˆ˜ ์žˆ๋‹ค.

Last updated