Created
February 13, 2019 05:05
-
-
Save ievgenk/bc18f0a44a31676e4888d11d80c418da to your computer and use it in GitHub Desktop.
React Hook Example
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, { useEffect, useState } from 'react'; | |
import Map from './components/Map'; | |
import axios from 'axios'; | |
const mapBoxToken: string = | |
'apikey'; | |
const getInitialMapPoint = (token: string) => { | |
axios | |
.get( | |
`https://api.mapbox.com/geocoding/v5/mapbox.places/oakridge+vancouver+bc+canada.json?access_token=${mapBoxToken}` | |
) | |
.then(data => { | |
console.log(data); | |
}); | |
}; | |
const App: React.FunctionComponent = () => { | |
const [initCoordinates, setInitCoordinate] = useState([0, 0]); | |
useEffect(() => { | |
getInitialMapPoint(mapBoxToken); | |
}); | |
return ( | |
<div> | |
<Map /> | |
</div> | |
); | |
}; | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment