Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot set property displayName on class which has only a getter #845

Closed
humulus opened this issue Feb 6, 2018 · 3 comments · May be fixed by Omrisnyk/npm-lockfiles#153
Closed

Cannot set property displayName on class which has only a getter #845

humulus opened this issue Feb 6, 2018 · 3 comments · May be fixed by Omrisnyk/npm-lockfiles#153
Assignees
Labels

Comments

@humulus
Copy link

humulus commented Feb 6, 2018

Description

This part of code is unable to set displayName because class has only getter's
react-hot-loader/packages/react-stand-in/src/createClassProxy.js

// Try to infer displayName
const displayName = getDisplayName(CurrentComponent)
ProxyFacade.displayName = displayName

Expected behavior

react-hot-loader should support classes with static getter's like

static get displayName() {
    return "button";
}

static get defaultProps() {
    return {
        type: "primary",
    };
}

Actual behavior

react-hot-loader/packages/react-stand-in/src/createClassProxy.js

Uncaught TypeError: Cannot set property displayName of function C3Chart() {
    _classCallCheck(this, C3Chart);

    return _possibleConstructorReturn(this, (C3Chart....<omitted>... } which has only a getter
    at update (createClassProxy.js?1dd3:210)

Environment

React Hot Loader version: 4.0.0-beta.21
Node version: v8.9.4
NPM version: 5.1.0
Ubuntu 14.04
Google Chrome: 64

@humulus
Copy link
Author

humulus commented Feb 6, 2018

temporary solution

if (process.env.NODE_ENV !== 'production') {
  Object.defineProperty(ClassObject, 'displayName', {
    set: function (val) {
      this.__displayName = val
    }
  });
}

I still think that createClassProxy should support static get displayName

@theKashey
Copy link
Collaborator

Ok, I'll just use safeDefineProperty as we use for the rest of props.

theKashey added a commit that referenced this issue Feb 13, 2018
gregberge pushed a commit that referenced this issue Feb 16, 2018
* safe define displayName, fix #845

* stand children did not exists, fix #843

* improve TS documentation

* add SSR+HRM example

* subrender - fix deferred updates

* dont fix package version

* should have react as a peer dep

* use didMount instead of will, related to #860
gregberge pushed a commit that referenced this issue Feb 18, 2018
* safe define displayName, fix #845

* stand children did not exists, fix #843

* improve TS documentation

* add SSR+HRM example

* subrender - fix deferred updates

* transfer original class methods into the Proxy prototype, fixes #858

* fix tests
@gregberge
Copy link
Collaborator

Should be fixed in beta.23.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants