Skip to content

Instantly share code, notes, and snippets.

@tristen
Last active August 23, 2020 13:07
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tristen/5c4b346ae38892f732504e6785d87057 to your computer and use it in GitHub Desktop.
Save tristen/5c4b346ae38892f732504e6785d87057 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'));
@techieshark
Copy link

techieshark commented Dec 26, 2019

Should

const style {
      position: 'absolute',
    ...
    };

be

const style = {
      position: 'absolute',
     ...
    };

(Add an =)?

@tristen
Copy link
Author

tristen commented Dec 26, 2019

@techieshark updated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment