File tree Expand file tree Collapse file tree 3 files changed +23
-2
lines changed
Expand file tree Collapse file tree 3 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,10 @@ const useGeoLocation = () => {
1919 const onError = ( error ) => {
2020 setLocation ( {
2121 loaded : true ,
22- error,
22+ error : {
23+ code : error . code ,
24+ message : error . message ,
25+ } ,
2326 } ) ;
2427 } ;
2528
Original file line number Diff line number Diff line change @@ -6,11 +6,13 @@ import useFullscreenMode from "hooks/useFullscreenMode";
66import ExternalInfo from "components/ExternalInfo" ;
77import ContactCard from "components/ContactCard" ;
88import useVisiblityToggler from "hooks/useVisiblityToggler" ;
9+ import useGeoLocation from "hooks/useGeoLocation" ;
910
1011const HooksDemo = ( ) => {
1112 const [ name , setName ] = useState ( "" ) ;
1213 const [ Prompt , setDirty , setPristine ] = useUnsavedChangesWarning ( ) ;
1314 const [ elementRef , FullscreenIcon ] = useFullscreenMode ( ) ;
15+ const location = useGeoLocation ( ) ;
1416
1517 const [ ContactCardComponent , toggleCardVisiblity ] = useVisiblityToggler (
1618 < ContactCard index = { 1 } name = "D'coders Tech" phone = "+959595959595" /> ,
@@ -96,6 +98,22 @@ const HooksDemo = () => {
9698 </ div >
9799 </ div >
98100 </ div >
101+
102+ < div class = "separator" > Hook 3: User Geo Location Hook</ div >
103+
104+ < div className = "row d-flex justify-content-center mt-3 mb-5 pb-5" >
105+ < div className = "col-6" >
106+ < div class = "card" >
107+ < div class = "card-header text-left font-weight-bold d-flex" >
108+ < div className = "inline-block mr-auto pt-1" >
109+ { location . loaded
110+ ? JSON . stringify ( location )
111+ : "Location data not available yet." }
112+ </ div >
113+ </ div >
114+ </ div >
115+ </ div >
116+ </ div >
99117 </ >
100118 ) ;
101119} ;
Original file line number Diff line number Diff line change @@ -88,7 +88,7 @@ const routes = [
8888 enabled : true ,
8989 path : "/hooks-demo" ,
9090 component : HooksDemo ,
91- navbar : "Hooks demo" ,
91+ navbar : "Custom Hooks demo" ,
9292 child : null ,
9393 } ,
9494 {
You can’t perform that action at this time.
0 commit comments