Skip to content

Instantly share code, notes, and snippets.

@haytastan
Forked from tristen/map.js
Created September 4, 2019 12:32
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 haytastan/693aeab705e80e917aaaa941c9b6ffe3 to your computer and use it in GitHub Desktop.
Save haytastan/693aeab705e80e917aaaa941c9b6ffe3 to your computer and use it in GitHub Desktop.
class Map extends React.Component {
componentDidMount() {
this.map = new mapboxgl.Map({
container: this.mapContainer,
style: 'mapbox://styles/mapbox/streets-v9'
});
}
componentWillUnmount() {
this.map.remove();
}
render() {
const style {
position: 'absolute',
top: 0,
bottom: 0,
width: '100%'
};
return <div style={style} ref={el => this.mapContainer = el} />;
}
}
ReactDOM.render(<Map />, document.getElementById('app'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment