This file contains hidden or 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, { | |
| useState, | |
| useEffect, | |
| useCallback, | |
| useRef, | |
| Fragment, | |
| } from 'react'; | |
| import moment from 'moment'; | |
| const SessionTimeout =()=> { |
This file contains hidden or 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
| const SessionTimeout = () => { | |
| const [events, setEvents] = useState(['click', 'load', 'scroll']); | |
| const [second, setSecond] = useState(0); |
This file contains hidden or 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
| let timeStamp; | |
| let warningInactiveInterval = useRef(); | |
| let startTimerInterval = useRef(); | |
| // start inactive check | |
| let timeChecker = () => { | |
| startTimerInterval.current = setTimeout(() => { | |
| let storedTimeStamp = sessionStorage.getItem('lastTimeStamp'); | |
| warningInactive(storedTimeStamp); | |
| }, 60000); |
This file contains hidden or 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
| // reset interval timer | |
| let resetTimer = useCallback(() => { | |
| clearTimeout(startTimerInterval.current); | |
| clearInterval(warningInactiveInterval.current); | |
| if (isAuthenticated) { | |
| timeStamp = moment(); | |
| sessionStorage.setItem('lastTimeStamp', timeStamp); | |
| } else { | |
| clearInterval(warningInactiveInterval.current); |
This file contains hidden or 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
| const SessionTimeout = () => { | |
| const [events, setEvents] = useState(['click', 'load', 'scroll']); | |
| const [second, setSecond] = useState(0); | |
| // reset interval timer | |
| let resetTimer = useCallback(() => { | |
| if (isAuthenticated) { | |
| timeStamp = moment(); | |
| sessionStorage.setItem('lastTimeStamp', timeStamp); |
This file contains hidden or 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
| const SessionTimeout = () => { | |
| const [events, setEvents] = useState(['click', 'load', 'scroll']); | |
| const [second, setSecond] = useState(0); | |
| let timeStamp; | |
| let warningInactiveInterval = useRef(); | |
| let startTimerInterval = useRef(); | |
| // start inactive check | |
| let timeChecker = () => { |
This file contains hidden or 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
| let timeStamp; | |
| let warningInactiveInterval = useRef(); | |
| let startTimerInterval = useRef(); | |
| // start inactive check | |
| let timeChecker = () => { | |
| startTimerInterval.current = setTimeout(() => { | |
| let storedTimeStamp = sessionStorage.getItem('lastTimeStamp'); | |
| warningInactive(storedTimeStamp); | |
| }, 60000); |
This file contains hidden or 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, useRef, useCallback } from 'react'; | |
| import mapboxgl from '!mapbox-gl'; // eslint-disable-line import/no-webpack-loader-syntax | |
| import mbxGeocoding from '@mapbox/mapbox-sdk/services/geocoding'; | |
| const GenerateMap = () => { | |
| return <React.Fragment /> | |
| } | |
| export default GenerateMap; |
This file contains hidden or 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
| const map = useRef(null); | |
| const mapContainerRef = useRef(null); | |
| mapboxgl.accessToken = process.env.REACT_APP_MAPBOX_API; // your mapbox api | |
| useEffect(() => { | |
| if (map.current) return; // Checks if there's an already existing map initialised. | |
| map.current = new mapboxgl.Map({ | |
| container: mapContainerRef.current, | |
| style: 'mapbox://styles/mapbox/streets-v11', |
This file contains hidden or 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
| return ( | |
| <div> | |
| <div ref={mapContainerRef} className='map-container' /> | |
| </div> | |
| ); |
OlderNewer