Skip to content

Instantly share code, notes, and snippets.

@NoFishLikeIan
Last active April 12, 2019 09:38
Show Gist options
  • Save NoFishLikeIan/0a2e8d43524f5b25ef9ebe0a33ae49cf to your computer and use it in GitHub Desktop.
Save NoFishLikeIan/0a2e8d43524f5b25ef9ebe0a33ae49cf to your computer and use it in GitHub Desktop.
Accurat suggestion for a decorator
import { observer, inject } from 'mobx-react'
const compose = (...fns) => {
const last = fns.slice(-1)[0]
const decorators = fns.slice(0, -1)
return decorators.reduceRight((v, f) => f(v), last);
}
export const SFComponents = compose(
observer,
inject('global'),
(props) => {
return <h1>Hello, {props.name}</h1>;
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment