Created
March 10, 2018 13:39
-
-
Save MicroBenz/66102eba6824730348d8b91fe4980fd8 to your computer and use it in GitHub Desktop.
React Context
This file contains hidden or 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 React, { Component } from 'react'; | |
import PropTypes from 'prop-types'; | |
class UIKitContext extends Component { | |
getChildContext() { | |
return { | |
path: (image, type) => `${this.props.prefixPath}/${type}/${image}` | |
}; | |
} | |
render() { | |
return ( | |
<div>{this.props.children}</div> | |
); | |
} | |
} | |
UIKitContext.propTypes = { | |
children: PropTypes.element, | |
prefixPath: PropTypes.string | |
}; | |
UIKitContext.childContextTypes = { | |
path: PropTypes.func | |
}; | |
export default UIKitContext; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment