Last active
May 10, 2018 15:25
-
-
Save joeynimu/f8adb510928fc8163aae9014e6b4abba to your computer and use it in GitHub Desktop.
Revisions
-
joeynimu revised this gist
May 10, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,7 @@ const Filters = () => { <h3>Some data</h3> <ul>{ regions && regions.map((d, i) => { return <li key={d.region_id}>{d.region_name}</li> }) }</ul> </div>) -
joeynimu revised this gist
May 9, 2018 . No changes.There are no files selected for viewing
-
joeynimu created this gist
May 9, 2018 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ import React from 'react' const Filters = () => { // this throws the error yet on inspecting with react tools I can see teh data `prop` with `regions` on there const regions = this.props.data.regions return (<div> <h3>Some data</h3> <ul>{ regions && regions.map((d, i) => { return <li key={d.region_id}>d.region_name</li> }) }</ul> </div>) } const areasQuery = ` query{ regions{ region_name region_id areas{ area_id collection_centers { collection_center_name } } } } ` export default DataProvider(Filters, areasQuery) 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ import React, { Component } from 'react' import { Provider, Client, query, Connect } from 'urql' import { GRAPHQL_ENDPOINT } from '../constants' const client = new Client({ url: GRAPHQL_ENDPOINT }) const DataProvider = (WrappedComponent, q) => { return class extends Component { render () { return (<Provider client={client}> <Connect query={query(q)} children={({ loaded, fetching, refetch, data, error }) => { return (<WrappedComponent data={data} {...this.props} />) }} /> </Provider>) } } } export default DataProvider