Last active
April 12, 2019 09:38
-
-
Save NoFishLikeIan/0a2e8d43524f5b25ef9ebe0a33ae49cf to your computer and use it in GitHub Desktop.
Accurat suggestion for a decorator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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