Created
October 10, 2016 10:50
-
-
Save MicheleBertoli/a42095f0cc6e31e5f2d0dfda3bc7dbcd to your computer and use it in GitHub Desktop.
Idle
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, { Component } from 'react'; | |
import ReactDOM from 'react-dom'; | |
import { Gmaps } from 'react-gmaps'; | |
const App = React.createClass({ | |
getInitialState() { | |
return { | |
loaded: false, | |
}; | |
}, | |
handleIdle() { | |
if (!this.state.loaded) { | |
console.log('do something only the first time the map is loaded'); | |
this.setState({ | |
loaded: true, | |
}); | |
} | |
}, | |
render() { | |
return ( | |
<div style={{ visibility: !this.state.loaded && 'hidden' }}> | |
<Gmaps | |
height={300} | |
lat={51.5258541} | |
lng={-0.08040660000006028} | |
onIdle={this.handleIdle} | |
width={400} | |
zoom={12} | |
/> | |
</div> | |
); | |
} | |
}); | |
ReactDOM.render(<App />, document.getElementById('gmaps')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment