Skip to content

Instantly share code, notes, and snippets.

@claym
Created July 8, 2017 00:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save claym/689342eb7e6b81e7fef05a2d1fe4d534 to your computer and use it in GitHub Desktop.
Save claym/689342eb7e6b81e7fef05a2d1fe4d534 to your computer and use it in GitHub Desktop.
import React from 'react';
import ReactDOM from 'react-dom';
import { graphql } from 'react-apollo';
import PropTypes from 'prop-types';
import Drawer from 'material-ui/Drawer';
import MenuItem from 'material-ui/MenuItem';
import allLocations from '../queries/all_locations.gql';
@graphql(allLocations)
class Sidebar extends React.Component {
static propTypes = {
data: PropTypes.shape({
loading: PropTypes.bool.isRequired,
allLocations: PropTypes.arrayOf(
PropTypes.shape({
name: PropTypes.string.isRequired,
id: PropTypes.number.isRequired,
}),
),
}),
}
render() {
console.log(this.props);
const { data: { loading, error, todos } } = this.props;
if (data.loading) {
return (<div>Loading Cities...</div>)
} else if (error) {
return (<div>Unable to load cities!</div>)
} else {
return (
<Drawer docked={true} style={{ width: 125 }}>
{data.allLocations.map(location =>
<MenuItem key={location.id}>{location.name}</MenuItem>
)}
</Drawer>
)
}
}
}
export default Sidebar;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment