'undefined is not a function' when using the new JSX transform
See original GitHub issueWhen importing an SVG, the new JSX transform doesn’t work seamlessly along with React 17. The resulting component with inlined SVG data looks as follows:
var TextAroundImageEditor_IconFlip = function IconFlip(props) {
return /*#__PURE__*/undefined("svg", TextAroundImageEditor_objectSpread(TextAroundImageEditor_objectSpread({}, props), {}, {
children: [/*#__PURE__*/Object(jsx_runtime_["jsx"])("path", {
fillRule: "evenodd",
d: "M8 3L2 19H11V3H8ZM4.886 17L9 6.02934V17H4.886Z"
}), /*#__PURE__*/Object(jsx_runtime_["jsx"])("path", {
fillRule: "evenodd",
d: "M16 3L22 19H13V3H16ZM19.114 17L15 6.02934V17H19.114Z"
})]
}));
};
TextAroundImageEditor_IconFlip.defaultProps = {
fill: "currentColor",
viewBox: "0 0 24 24",
width: "24",
height: "24",
xmlns: "http://www.w3.org/2000/svg"
};
Instead of something similar to:
var TextAroundImageEditor_IconFlip = function IconFlip(props) {
+ return /*#__PURE__*/Object(jsx_runtime_["jsx"])("svg", TextAroundImageEditor_objectSpread(TextAroundImageEditor_objectSpread({}, props), {}, {
- return /*#__PURE__*/undefined("svg", TextAroundImageEditor_objectSpread(TextAroundImageEditor_objectSpread({}, props), {}, {
children: [/*#__PURE__*/Object(jsx_runtime_["jsx"])("path", {
Issue Analytics
- State:
- Created 3 years ago
- Reactions:14
- Comments:14
Top Results From Across the Web
Rollup + React 17 with new JSX Transform - Stack Overflow
2 Answers 2 · 1. In my library built using rollup I get this error when I try to do that: Error: 'jsx'...
Read more >Documentation - JSX - TypeScript
JSX is an embeddable XML-like syntax. It is meant to be transformed into valid JavaScript, though the semantics of that transformation are ...
Read more >JavaScript: Uncaught TypeError: n is not a function
This error occurs if you try to execute a function that is not initialized or is not initialized correctly. This means that the...
Read more >The 10 Most Common JavaScript Issues Developers Face
Uncaught TypeError : undefined is not a function. Why? It's all about context. The reason you get the above error is because, when...
Read more >Strict mode - JavaScript - MDN Web Docs
function sum(a = 1, b = 2) { // SyntaxError: "use strict" not ... mistyping a variable in an assignment creates a new...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
For Next.js 10, I’m currently using the following workaround:
Also, I’ve opened an issue to support simplifying the config given above:
Hey fellas, I wrote a fix for this in my fork.
You can test this today using
yarn add -D @simplyianm/babel-plugin-inline-react-svg
.Here’s my config which uses
next
andemotion
:Cheers!
https://github.com/airbnb/babel-plugin-inline-react-svg/pull/94