【问题标题】:what is difference between values 'react' and 'react-jsx' for 'jsx' property in compiler options of tsconfigtsconfig 编译器选项中 \'jsx\' 属性的值 \'react\' 和 \'react-jsx\' 有什么区别
【发布时间】:2022-08-23 20:29:48
【问题描述】:

如果我们看看https://www.typescriptlang.org/docs/handbook/jsx.html#basic-usage
jsx 属性中添加了更多值,即 1. react-jsx 和 2. react-jsxdev

react-jsxreact 有什么实际好处?

  • 如果有人可以添加 react-jsxdev 的用处,那就太好了!

标签: reactjs compilation jsx tsconfig


【解决方案1】:

根据我的观察和阅读以下两个链接
1.https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html
2.https://www.typescriptlang.org/docs/handbook/jsx.html#basic-usage

如果我们使用react-jsx而不是react,ts编译器会输出_jsx(),而不是React.createElement()

因此我们可以避免在我们定义组件的文件中导入 React,只是为了使用 jsx 语法

【讨论】:

    猜你喜欢
    • 2023-02-25
    • 2014-11-20
    • 1970-01-01
    • 2020-11-21
    • 2019-03-23
    • 2023-03-07
    • 2017-09-23
    • 1970-01-01
    • 2016-12-22
    相关资源
    最近更新 更多