Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

Gatsby reverted support for new JSX transform (which is from React 17). If you need this, you should setup babel (and maybe typescript)

babel.config.js

module.exports = function(api) {
  api.cache(true)

  const presets = [
    [
      "babel-preset-gatsby",
      {
        reactRuntime: 'automatic'
      },
    ],
  ]

  const plugins = []

  return {
    presets,
    plugins,
  }
}

tsconfig.js

{
  "jsx": "react-jsx"
}

Also need React 17, babel-preset-gatsby >= 0.5.8.

References:

https://github.com/gatsbyjs/gatsby/tree/master/packages/babel-preset-gatsby https://devblogs.microsoft.com/typescript/announcing-typescript-4-1-beta/#jsx-factories

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment