본문 바로가기

[Dev] 🎯Self Study/[코딩] 너 또 오류나 ? error 모음집

[너 또 오류나? ts] 'React' refers to a UMD global, but the current file is a module. Consider adding an import instead.ts(2686)

next 기본파일에서 오류가 난다. 

(저 아무것도 안했는데 왜...)

 

'React' refers to a UMD global, but the current file is a module. Consider adding an import instead.ts(2686)

 

이럴 때는 quick fix를 눌러보자. (ctrl  + . )

 

import React from "react";
import { Button, Header } from "ui";

export default function Page() {
  return (
    <>
      <Header text="Web" />
      <Button />
    </>
  );
}

 

혹은 이 첫줄이 다르게 써져서 오류가 난다면 ... 

 

TypeScript errors and how to fix them

A list of common TypeScript errors and how to fix them.

typescript.tv

 import * as React from "react";

이렇게 바꿔주면 된다.