Created
May 26, 2017 16:51
-
-
Save ticklemynausea/730dc56699a8723ddc2b3601b6d3f888 to your computer and use it in GitHub Desktop.
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 from "react"; | |
| import PropTypes from "prop-types"; | |
| const withContext = function(WrappedComponent, context) { | |
| class ContextProvider extends React.Component { | |
| constructor(...args) { | |
| super(...args); | |
| } | |
| getChildContext() { | |
| return context; | |
| } | |
| render() { | |
| return (<WrappedComponent {...this.props} />); | |
| } | |
| } | |
| ContextProvider.childContextTypes = {}; | |
| Object.keys(context).forEach(key => { | |
| ContextProvider.childContextTypes[key] = PropTypes.any.isRequired; | |
| }); | |
| return ContextProvider; | |
| }; | |
| export default withContext; | |
| /* https://stackoverflow.com/questions/43465480/react-router-link-doesnt-work-with-leafletjs/43594791 */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment