Last active
May 27, 2020 20:01
-
-
Save apaleslimghost/144d03429a22595aa24247f8e4963289 to your computer and use it in GitHub Desktop.
name:@quarterto/styled-compose
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
const {createElement: h} = require('react') | |
module.exports = (...styles) => styles.reduce( | |
(prev, component) => { | |
function Composed(props) { | |
return h(component, Object.assign({}, props, {as: prev})) | |
} | |
Composed.displayName = component.displayName || component.name | |
return Composed | |
} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment