question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug issue with babel-plugin-transform-react-constant-elements

See original GitHub issue

When I work on my React Project, I usually put the component files in a directory and create a index.js so that I can load the components like import { UserInfo, AnotherComponent } from 'container';

Today, I tried using that structure with create-react-app. It works perfectly on the dev-server, but it gives following error when I try to load the component:

React: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined.

My have uploaded the directory structure and codes on gist: https://gist.github.com/velopert/ab6e132d73a17930c90e3e38493c12ed

It seems like there’s no problem if I import and render the components from outside of the directory. (For example, I can import and render App component from src/index.js, if I do not render UserInfo from App component). I tried console.log(<UserInfo/>) from App, and it seems like there is no problem with importing the module. I think there is an issue with rendering it.

Anyways, I just have found out that the babel-plugin-transform-react-constant-elements is the one that causes problem. I commented out the babel-plugin-transform-react-constant-elements part from the babel.prod.js and it works fine again.

Thanks !

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

github_iconTop Results From Across the Web

[Bug]: After upgrading to babel-plugin-transform-react ... - GitHub
[Bug]: After upgrading to babel-plugin-transform-react-constant-elements v7.17.6 our application has stopped working correctly #14363.
Read more >
Shorthand React prop causing reference error with transform ...
Apparently the issue is caused by the transform-react-constant-elements Babel plugin during the rendition of the component below: // This gives ...
Read more >
Bug with babel-plugin-transform-react-constant-elements
Using babel-plugin-transform-react-constant-elements version 6.23.0 , i'm getting an error which is not transforming well the code and webpack explodes.
Read more >
@babel/plugin-transform-react-jsx-source - Package Manager
Fast, reliable, and secure dependency management.
Read more >
babel-plugin-transform-react-constant-elements - npm package
The npm package babel-plugin-transform-react-constant-elements was scanned for known vulnerabilities and missing license, and no issues were found. Thus the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Hashnode Post

No results found