Skip to content

Latest commit

 

History

History
40 lines (28 loc) · 815 Bytes

withStyles.md

File metadata and controls

40 lines (28 loc) · 815 Bytes

withStyles() Addon

withStyles() is a higher order component, which injects styles props.

const cssMap = {
    main: {
        border: '1px solid red'
    }
};

const MyComp = withStyles(cssMap, ({styles}) => {
    return <div className={styles.main} />
});

You can specify the name our your component as a third argument.

withStyles(cssMap, MyComp, 'MyComponent');

Or you can name your function, in that case the function name will be automatically picked up.

const MyComp = withStyles(cssMap, function MyComponent ({styles}) {
    return <div className={styles.main} />
});

Installation

Install withStyles addon and its dependencies:

Read more about the Addon Installation.