26 lines
571 B
JavaScript
26 lines
571 B
JavaScript
import React from 'react'
|
|
import ReactDOM from 'react-dom'
|
|
|
|
class App extends React.Component {
|
|
|
|
// specific to JS not to React
|
|
constructor(props) {
|
|
super(props)
|
|
this.state = { lat: null }
|
|
|
|
window.navigator.geolocation.getCurrentPosition(
|
|
postion => {
|
|
this.setState({ lat: postion.coords.latitude })
|
|
},
|
|
err => console.log(err)
|
|
)
|
|
}
|
|
|
|
render() {
|
|
return <div>Latitude: {this.state.lat}</div>
|
|
}
|
|
}
|
|
ReactDOM.render(
|
|
<App />,
|
|
document.querySelector('#root')
|
|
) |