반응형
임포트방식
-
모듈 호출 방식 (import, require)프레임워크/리액트 React 2024. 7. 9. 16:53
모듈 호출 방식 (import, require)리액트 프로젝트에선 ES6 방식인 import 방식을 더 사용하지만, 필요에 따라 import를 쓰기도, CommonJS 방식인 require를 쓰기도 한다. 1. import 방식 / ES6 모듈ES6 모듈: import { createBrowserRouter } from "react-router-dom"; 2. require 방식 / CommonJSconst { createBrowserRouter } = require("react-router-dom");3. 차이점방식 ES6 / import CommonJs / require 임포트 시점정적 임포트 / 컴파일 시점동적 임포트 / 런타임 시점데이터 교환 방식import - export를 통해 모듈 간 데..