Skip to content

Latest commit

 

History

History
32 lines (27 loc) · 1.15 KB

28.decorators.md

File metadata and controls

32 lines (27 loc) · 1.15 KB

Decorators

Decorators (supported by Babel, in Stage 2 proposal as of 03/17)

If you’re using something like mobx, you can decorate your class components — which is the same as passing the component into a function. Decorators are flexible and readable way of modifying component functionality.

Article:

Related:

Non-decorators approach

class ProfileContainer extends Component {
  // Component code
}
export default observer(ProfileContainer)

With decorators

@observer
export default class ProfileContainer extends Component {
  // Component code
}

Check for a Decorator example here: https://github.com/gigobyte/react-document-title-decorator