Skip to content

Instantly share code, notes, and snippets.

@jwoo0122
Last active December 12, 2020 19:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jwoo0122/4e404682ce0b3b684a989a336dade350 to your computer and use it in GitHub Desktop.
Save jwoo0122/4e404682ce0b3b684a989a336dade350 to your computer and use it in GitHub Desktop.

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