Vite2 + vue3 uses JSX to report an error: react is not defined
If JSX
is not used in react
, for error reporting:
React is not defined
It is required to add the following configuration to the vite.config.js
file:
export default {
esbuild: {
jsxFactory: 'h',
jsxFragment: 'Fragment',
jsxInject: "import { h } from 'vue';"
}
}
The last sentence is equivalent to the injection of vite. The helper automatically introduces h
Read More:
- [Solved] vite package Error: globalThis is not defined
- [Solved] vue3vite Error: Failed to resolve import “@vue/server-renderer from “src\App.vue“. Does the file exist
- How to Solve “Vue is not defined” Error
- [Solved] Vue item error: Regeneratorruntime is not defined
- [Solved] Vue 3 Script Setup ESLint Error: ‘defineProps‘ is not defined
- [Solved] Vue3 process Error: Uncaught ReferenceError: process is not defined
- vue eslint error ‘process‘ is not defined no-undef [How to Solve]
- Ant design vue table Error: h is not defined [How to Solve]
- [Solved] React Error: ReactDOM.render is no longer supported in React 18.
- [Solved] Vue Project Start Error: Support for the experimental syntax ‘jsx‘ isn‘t currently enabled
- [Solved] Temporary error: Error: spawn E:\vue3-vite\my-app\node_modules\esbuild\esbuild.exe ENOENT
- Vue3 + vite install element-plus error [How to Solve]
- [Solved] react-router-dom Error: index.js:1 Warning: Functions are not valid as a React child.
- vue error: ‘ev’ is defined but never used (no-unused-vars)
- [Solved] React Dependency Error: Invalid tag name “^np.0.2“ of package “react@^np.0.2“: Tags may not have an
- [Solved] Vue Error: template or render function not defined
- [Solved] Vue Error: error ‘xxx‘ is defined but never used no-unused-vars
- [Solved] Vuepress Package Error: document is not defined
- [Solved] Vue Error: error: ‘to‘ is defined but never used (no-unused-vars)
- [Solved] Vue Error: Uncaught TypeError: Vue.createApp is not a function