Created
July 8, 2017 00:12
-
-
Save claym/689342eb7e6b81e7fef05a2d1fe4d534 to your computer and use it in GitHub Desktop.
This file contains 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 characters
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