Skip to content

Instantly share code, notes, and snippets.

@ticklemynausea
Created May 26, 2017 16:51
Show Gist options
  • Select an option

  • Save ticklemynausea/730dc56699a8723ddc2b3601b6d3f888 to your computer and use it in GitHub Desktop.

Select an option

Save ticklemynausea/730dc56699a8723ddc2b3601b6d3f888 to your computer and use it in GitHub Desktop.
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