Giter VIP home page Giter VIP logo

Comments (6)

loganfsmyth avatar loganfsmyth commented on May 12, 2024

Would you be able to trim down a reproducible version with a simple decorator? I don't know how connect works. If not I can give it a shot eventually.

from babel-plugin-transform-decorators-legacy.

nd0ut avatar nd0ut commented on May 12, 2024

@loganfsmyth hmm, it seems that there is problem with react-redux connect decorator cause with simple decorator all works fine. Sorry for disturbing.

from babel-plugin-transform-decorators-legacy.

nd0ut avatar nd0ut commented on May 12, 2024

I was wrong.

function wrap(wrappedComponent) {
    class Wrapper extends React.Component {
        render() {
            return React.createElement(wrappedComponent, this.props);
        }
    }
    return Wrapper;
};

@wrap
export class Node extends React.Component {

    render() {
        const nodes = [
            <Node alone />,
            <Node alone />,
            <Node alone />
        ];

        if(this.props.alone) {
            return <div>Node</div>;
        }
        else {
            return <div>{nodes}</div>;
        }
    }
}

As result: one wrapper, many nodes.

Expected: each node wrapped by wrapper (babel-5 behavior)

from babel-plugin-transform-decorators-legacy.

loganfsmyth avatar loganfsmyth commented on May 12, 2024

Perfect, thanks for the great example. I've got a busy week, but I'll try to get to this when I can.

from babel-plugin-transform-decorators-legacy.

loganfsmyth avatar loganfsmyth commented on May 12, 2024

I'm a little on the fence on this, now that I look into it more. It seems like an edge-case where Babel 5's behavior differers from my reading of the spec. The https://github.com/wycats/javascript-decorators#desugaring-es6 ES6 class desugaring example from the decorator repo is the logic that I follow in this implementation. My reading of that would imply that usage of Note within the Note class body, would still refer to the original class constructor, not the one returned from the decorator function.

At the moment, I'm tempted to lean toward adding this as a third entry in the "Best Effort" list in the README.

from babel-plugin-transform-decorators-legacy.

amino-studio avatar amino-studio commented on May 12, 2024

Any updates?

from babel-plugin-transform-decorators-legacy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.