You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a Base class called BaseModel, and multiple sub-classes like User, Foo, Bar, etc. They all extend BaseModel. The BaseModel class has some logic like:
This allows me to have a reference to all instances of the class. The problem is that deploying the app renames all sub-classes to "a" (instead of using "a", "b", etc. for different sub-classes). Hence, my _instances map has multiple model class instances under the same key, causing issues.
So I have:
class User extends BaseModel {}
class Foo extends BaseModel {}
class Bar extends BaseModel {}
But in production code, the this.constructor.name is "a" for all of them (User, Foo, Bar).
Did you try recovering your dependencies?
N/A
Environment
current version of create-react-app: 5.0.0
running from /Users/jashsayani/.npm/_npx/c67e74de0542c87c/node_modules/create-react-app
System:
OS: macOS 12.1
CPU: (8) arm64 Apple M1 Pro
Binaries:
Node: 16.13.0 - /usr/local/bin/node
Yarn: Not Found
npm: 8.1.0 - /usr/local/bin/npm
Browsers:
Chrome: 96.0.4664.110
Edge: Not Found
Firefox: Not Found
Safari: 15.2
npmPackages:
react: ^17.0.1 => 17.0.1
react-dom: ^17.0.1 => 17.0.1
react-scripts: 4.0.1 => 4.0.1
npmGlobalPackages:
create-react-app: Not Found
Steps to reproduce
Create class BaseModel and copy constructor from above.
Create sub-classes User, Foo, Bar, etc.
Create instances of User, Foo, Bar, etc. (const f = new Foo();)
Notice that value of this.constructor.name is "a" in constructor (when creating instance of Foo, Bar, etc.) with deploy build code (NOT local server)
Expected behavior
Values of this.constructor.name should be "a", "b", "c", etc. based on different sub-classes
Actual behavior
Creating instances of multiple sub-classes results in this.constructor.name to be "a".
The text was updated successfully, but these errors were encountered:
I see people using eject and overriding webpack config to get around this. I do not want to eject, how can I preserve class names for now? (that seems to be the only solution at this time)
The docs for create-react-app dont mention having a config to override build rules.
Describe the bug
I have a Base class called BaseModel, and multiple sub-classes like User, Foo, Bar, etc. They all extend BaseModel. The BaseModel class has some logic like:
This allows me to have a reference to all instances of the class. The problem is that deploying the app renames all sub-classes to "a" (instead of using "a", "b", etc. for different sub-classes). Hence, my
_instances
map has multiple model class instances under the same key, causing issues.So I have:
But in production code, the
this.constructor.name
is "a" for all of them (User, Foo, Bar).Did you try recovering your dependencies?
N/A
Environment
Steps to reproduce
BaseModel
and copy constructor from above.const f = new Foo();
)this.constructor.name
is "a" in constructor (when creating instance of Foo, Bar, etc.) with deploy build code (NOT local server)Expected behavior
Values of
this.constructor.name
should be "a", "b", "c", etc. based on different sub-classesActual behavior
Creating instances of multiple sub-classes results in
this.constructor.name
to be "a".The text was updated successfully, but these errors were encountered: