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

Broken in higher-order components #8

Closed
ctumolosus opened this issue Mar 14, 2017 · 5 comments
Closed

Broken in higher-order components #8

ctumolosus opened this issue Mar 14, 2017 · 5 comments
Labels

Comments

@ctumolosus
Copy link

I tried using this plugin in my project but got the following error when compiling higher-order components:

We don't know what to do with this node type. We were previously a Statement but we can't fit in here?
    at NodePath.insertAfter (~/babel-traverse/lib/path/modification.js:175:13)
    at insertAfterPath (~/node_modules/babel-plugin-transform-react-handled-props/lib/util/appendProps.js:50:27)
    at ~/node_modules/babel-plugin-transform-react-handled-props/lib/util/appendProps.js:59:5

Here is a snippet reproducing the problem:

import React from 'react';

export default function WithSauce(options = {}) {
  return function createContainer(Component) {
    return class Sauce extends React.Component {
      render() {
        return (
          <Component className="sauced" />
        );
      }
    };
  };
}

I tried changing my syntax a bit and got a different problem (possibly unrelated)

export default (options) => (Component) => class WithSauce extends React.Component { [...] }

Transpiled to:

module.exports = function (options) {
  return function (Component) {
    return function WithSauce() { [...] }
  }
}

WithSauce.handledProps = []; // Error: WithSauce is not defined.

Let me know if there is anything else I can help with to identify the root cause.

@layershifter
Copy link
Owner

@ctumolosus Thanks for detailed report. I will fix it as soon as i can.

@gadyonysh
Copy link

How about fix?

@layershifter
Copy link
Owner

I will fix this issue on this week. Thanks for notify

@layershifter
Copy link
Owner

Sorry for delay, guys.
Fixed in 0.2.4. Will be nice to have a feedback there.

@gadyonysh
Copy link

Works fine for me. Thank you for fixing.

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

No branches or pull requests

3 participants