简体   繁体   中英

How to fix vite warning: The JSX import source cannot be set?

I'm running a react app with vite using emotion css. In order to use the css attritbute of emotions on html-elements I need to set a special comment to enable a vite build:

/** @jsxImportSource @emotion/react */
import { css, jsx } from "@emotion/react"

It used to work fine but now I get the following warning and I don't know what it means and how to fix it:

[vite] warning: The JSX import source cannot be set without also enabling React's "automatic" JSX transform

Try to add this into your tsconfig.json

{
  "compilerOptions": {
    ...
    "jsxImportSource": "@emotion/react",
    ...
  },
}

Source: https://emotion.sh/docs/typescript#emotionreact

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM