最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

React-App-Rewired (compiling) "Icons" is not defined (cache issue) - Stack Overflow

programmeradmin0浏览0评论
  • I've compiled versions of this code many times over the past few years.

  • It also runs fine in development mode, it just won't compile to staging (or production).

  • VS Code isn't reporting any errors or warnings

The word "Icons" (case-sensitive) is not anywhere in my code-base. I did name an object that, but I renamed it to SiteIcons. It was telling me that Icons was undefined, when it clearly shouldn't have been.

But when I run react-app-rewired build --config-overrides=./config-overrides.js, (file and command are unchanged from last several compiles), I get dozens of errors throughout the project like this,

Line 115:42:  'Icons' is not defined  react/jsx-no-undef

and some other calls to Material Icons that I've now moved to this object

Line 298:141:  'ReceiptLongRounded' is not defined  react/jsx-no-undef
Line 330:52:   'PasswordRounded' is not defined    react/jsx-no-undef

But when i follow to a linked file to any of these reports

src\views\_widgets\short-form.tsx
  Line 194:56:  'ErrorTwoTone' is not defined  react/jsx-no-undef

I see that the code at that line actually says, as it's supposed to

<SiteIcons.ErrorTwoTone />

I've tried clearing the npm cache, the babel cache, and restarting the machine

  • I've compiled versions of this code many times over the past few years.

  • It also runs fine in development mode, it just won't compile to staging (or production).

  • VS Code isn't reporting any errors or warnings

The word "Icons" (case-sensitive) is not anywhere in my code-base. I did name an object that, but I renamed it to SiteIcons. It was telling me that Icons was undefined, when it clearly shouldn't have been.

But when I run react-app-rewired build --config-overrides=./config-overrides.js, (file and command are unchanged from last several compiles), I get dozens of errors throughout the project like this,

Line 115:42:  'Icons' is not defined  react/jsx-no-undef

and some other calls to Material Icons that I've now moved to this object

Line 298:141:  'ReceiptLongRounded' is not defined  react/jsx-no-undef
Line 330:52:   'PasswordRounded' is not defined    react/jsx-no-undef

But when i follow to a linked file to any of these reports

src\views\_widgets\short-form.tsx
  Line 194:56:  'ErrorTwoTone' is not defined  react/jsx-no-undef

I see that the code at that line actually says, as it's supposed to

<SiteIcons.ErrorTwoTone />

I've tried clearing the npm cache, the babel cache, and restarting the machine

Share Improve this question asked Mar 13 at 21:18 Regular JoRegular Jo 5,5003 gold badges26 silver badges53 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

I was able to solve this weird cache issue by effectively touching each file.

Honestly, I just ran a project-wide replace of ^import SiteIcons with $0 in VSCode.

After this, the project compiled fine, no more mysterious undef issues.

发布评论

评论列表(0)

  1. 暂无评论