Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
746b3c3
commit 2a47579
Showing
5 changed files
with
86 additions
and
23 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React from 'react'; | ||
import Header from './Header'; | ||
import { useCurrentCoords } from '../../hooks'; | ||
|
||
function HeaderContainer() { | ||
const { refreshCoords } = useCurrentCoords(); | ||
|
||
return <Header refreshCoords={refreshCoords} />; | ||
} | ||
|
||
export default HeaderContainer; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export { default as Header } from './Header'; | ||
export { default as Header } from './HeaderContainer'; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { localStorage } from './localStorage'; | ||
|
||
async function getCoords() { | ||
return new Promise((resolve, reject) => { | ||
navigator.geolocation.getCurrentPosition( | ||
({ coords }) => { | ||
localStorage.setItem('coords', { | ||
latitude: coords.latitude, | ||
longitude: coords.longitude, | ||
}); | ||
|
||
resolve(coords); | ||
}, | ||
(error) => { | ||
reject(error); | ||
}, | ||
{ timeout: 5000 }, | ||
); | ||
}); | ||
} | ||
|
||
export { getCoords }; |