mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-21 10:03:31 +00:00
35 lines
737 B
JavaScript
35 lines
737 B
JavaScript
const React = require('react');
|
|
const { Provider } = require('react-redux');
|
|
|
|
const ContextShape = require('../propTypes/Context');
|
|
|
|
/**
|
|
* React component to provide a GitBook context to children components.
|
|
*/
|
|
|
|
const ContextProvider = React.createClass({
|
|
propTypes: {
|
|
context: ContextShape.isRequired,
|
|
children: React.PropTypes.node
|
|
},
|
|
|
|
childContextTypes: {
|
|
gitbook: ContextShape
|
|
},
|
|
|
|
getChildContext() {
|
|
const { context } = this.props;
|
|
|
|
return {
|
|
gitbook: context
|
|
};
|
|
},
|
|
|
|
render() {
|
|
const { context, children } = this.props;
|
|
return <Provider store={context.store}>{children}</Provider>;
|
|
}
|
|
});
|
|
|
|
module.exports = ContextProvider;
|