File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Load diff This file was deleted.
Original file line number Diff line number Diff line change 11module . exports = {
22 siteMetadata : {
33 title : 'JavaScriptMN' ,
4+ apiRoot : 'https://next-meetup-proxy-dnfelnhlmh.now.sh'
45 } ,
56 plugins : [
67 'gatsby-plugin-react-helmet' ,
Original file line number Diff line number Diff line change 11import React , { Component } from 'react'
2+ import PropTypes from 'prop-types'
23import format from 'date-fns/format'
34import 'whatwg-fetch'
4- import config from '../../config.json '
5+ import { graphql , StaticQuery } from 'gatsby '
56
6- const NEXT_MEETUP_URI = config . apiRoot
77
88const MeetupDescription = ( { name, time, venue } ) => (
99 < div className = "next-event" >
@@ -37,7 +37,7 @@ class Meetup extends Component {
3737 error : false ,
3838 } )
3939 window
40- . fetch ( NEXT_MEETUP_URI )
40+ . fetch ( this . props . apiRoot )
4141 . then ( res => res . json ( ) )
4242 . then ( ( { name, time, venue } ) =>
4343 this . setState ( {
@@ -88,4 +88,22 @@ class Meetup extends Component {
8888 }
8989}
9090
91- export default Meetup
91+ Meetup . propTypes = {
92+ apiRoot : PropTypes . string . isRequired ,
93+ }
94+
95+ const WrappedMeetup = ( ) => (
96+ < StaticQuery
97+ query = { graphql `
98+ query SiteApiRootQuery {
99+ site {
100+ siteMetadata {
101+ apiRoot
102+ }
103+ }
104+ }
105+ ` }
106+ render = { data => < Meetup apiRoot = { data . site . siteMetadata . apiRoot } /> } />
107+ )
108+
109+ export default WrappedMeetup
You can’t perform that action at this time.
0 commit comments