theme-ui: Syntax error: pragma and pragmaFrag cannot be set when runtime is automatic.
I started having this error since updating Gatsby to the most recent version and updating React to v17.
Syntax error: pragma and pragmaFrag cannot be set when runtime is automatic.
edit: The same issue now exists with the latest version of React react@16.14.0, right now the only fix is to go back to react@16.13.1 and react-dom@16.13.1
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 17
- Comments: 18 (9 by maintainers)
Commits related to this issue
- fix(deps): pin react version - due to this issue - https://github.com/system-ui/theme-ui/issues/1160 — committed to JasonSooter/jasonsooter.com by JasonSooter 4 years ago
- Fix pragma https://github.com/system-ui/theme-ui/issues/1160 — committed to pythonitalia/pycon by patrick91 4 years ago
- Fix pragma https://github.com/system-ui/theme-ui/issues/1160 — committed to pythonitalia/pycon by patrick91 4 years ago
- Fix pragma https://github.com/system-ui/theme-ui/issues/1160 — committed to pythonitalia/pycon by patrick91 4 years ago
- Fix pragma https://github.com/system-ui/theme-ui/issues/1160 — committed to pythonitalia/pycon by patrick91 4 years ago
- fix: attempt to solve runtime issue See: https://github.com/system-ui/theme-ui/issues/1160 — committed to technologiestiftung/berlin-iot-hub-frontend by dnsos 3 years ago
Just adding here in case anyone sees this error message after upgrading a project to create-react-app v4:
Theme UI currently only supports the classic JSX runtime. Until emotion is upgraded to support the automatic runtime and Theme UI can be upgraded, add the comment
/** @jsxRuntime classic */to all files using thesxprop. This should fix the issue.You can also disable the automatic runtime globally instead by setting the environment variable
DISABLE_NEW_JSX_TRANSFORM=true, e.g. in your.envfile.Confirming it works with dependencies:
Waiting for https://github.com/emotion-js/emotion/pull/1970 or alternative work in Emotion.
Seems like Emotion was upgraded in order to support new JSX Runtime : https://github.com/emotion-js/emotion/blob/master/packages/core/CHANGELOG.md Just waiting Theme-UI upgrade now š
Nice catch!
To support automatic runtime, weāll need to add
_jsxand_jsxsexports to theme-ui, and then update transform-react-jsx config.https://babeljs.io/docs/en/babel-plugin-transform-react-jsx#react-automatic-runtime
As a workaround, you can change your runtime to
classic.I never interpreted the title of this issue as āplease make pragmaFrag work in automatic runtimeā, but I think youāre right. We also need to update the docs to educate about classic and automatic runtime, and change
/* @jsx jsx */occurences in there to@jsxImportSource, as automatic runtime became the default.https://github.com/system-ui/theme-ui/pull/1237 will close this.
I have the same problem. Here is my dependencies:
It is working with
react@16.13.1andreact-dom@16.13.1. Thanks to tc2a.Most recent version,
gatsby@2.24.78What
gatsbyversion are you on?I believe these issues are because of recent changes to React. I got it working with
gatsby-plugin-theme-ui@0.3.0andreact@16.13.1andreact-dom@16.13.1