Import in body of module; reorder to top import/first 에러 해결법

onezerokang·2021년 7월 5일
0
post-thumbnail

React를 사용하다가 다음과 같은 에러를 마주했다.

Import in body of module; reorder to top  import/first

위 에러는 모듈을 모두 import하기전에 변수, 상수를 선언하면 발생하는 에러였다. 다음은 에러가 났던 코드다.

에러가 난 코드

import React, { useEffect, useState } from "react";
import axios from "axios";
import { Icon, Col, Card, Row } from "antd";
const { Meta } = Card;
import ImageSlider from "../../utils/ImageSlider.js";

ImageSlider를 import하기 전에 Meta변수를 선언, 할당해서 에러가 발생했던 것이다. 다음과 같이 코드를 고쳤더니 문제가 해결되었다.

고친 코드

import React, { useEffect, useState } from "react";
import axios from "axios";
import { Icon, Col, Card, Row } from "antd";
import ImageSlider from "../../utils/ImageSlider.js";
const { Meta } = Card;

출처
https://stackoverflow.com/questions/50135723/import-in-body-of-module-reorder-to-top-import-first-across-many-files

profile
블로그 이전 했습니다: https://techpedia.tistory.com

0개의 댓글