Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

Decorate a function #35

Closed
Closed

Description

Here is my story:

Firstly, I wrote React components using HOCs pattern. Say, I have some hocs and compose them into a component like this:

compose(
  hoc1,
  hoc2,
  ...
)(function MyComponent (props) {...})

Then, I learned the decorator syntax and changed my code into such format:

@hoc1
@hoc2
...
class MyComponent extends React.Component {
  render () {...}
}

But this is not perfect. The final great format should be like this:

@hoc1
@hoc2
...
function MyComponent (props) {...}

But currently decorator can not be applied to function, so sad :(

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions