File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { Component , Children , PropTypes } from 'react' ;
2
+
3
+ const propTypes = {
4
+ urls : PropTypes . object ,
5
+ children : PropTypes . array ,
6
+ } ;
7
+ const defaultProps = {
8
+ urls : { } ,
9
+ } ;
10
+ const childContextTypes = {
11
+ urls : PropTypes . object ,
12
+ } ;
13
+
14
+ /**
15
+ * Set URLs object to React application context
16
+ * @param {Object } urls URL to set
17
+ * @param {Class } children Application component
18
+ */
19
+ class UrlProvider extends Component {
20
+ getChildContext ( ) {
21
+ return {
22
+ urls : this . props . urls ,
23
+ } ;
24
+ }
25
+
26
+ render ( ) {
27
+ return Children . only ( this . props . children [ 0 ] ) ;
28
+ }
29
+ }
30
+
31
+ UrlProvider . propTypes = propTypes ;
32
+ UrlProvider . defaultProps = defaultProps ;
33
+ UrlProvider . childContextTypes = childContextTypes ;
34
+
35
+ export default UrlProvider ;
You can’t perform that action at this time.
0 commit comments