-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created the start of a route logger. Changed the PieChart to be "flip…
…pable" and see the data on the other side.
- Loading branch information
Showing
4 changed files
with
133 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React, {useState, useEffect} from 'react'; | ||
import {useLocation} from "react-router-dom"; | ||
|
||
//TODO: Maybe save all events in local storage, up to 500 events | ||
// Create another component that creates a chart using that data structure from local storage. | ||
|
||
/** | ||
* Work in progress but basically a component that logs location changes | ||
* @returns {null} | ||
* @constructor | ||
*/ | ||
export const LogRoute = () => { | ||
const location = useLocation(); | ||
const [events, setEvents] = useState([]); | ||
|
||
useEffect(() => { | ||
const eventDate = new Date(); | ||
const event = { | ||
path: location.pathname, | ||
search: location.search, | ||
when: eventDate.toISOString() | ||
}; | ||
setEvents(current => current.concat(event)); | ||
}, [location.pathname, location.search]); | ||
|
||
useEffect(() => { | ||
if(events.length >= 15){ | ||
console.log('Greater than or equal to 15 submitting'); | ||
console.log(events); | ||
setEvents([]); | ||
} | ||
}, [events.length]); | ||
|
||
return null; | ||
}; | ||
|
||
export default LogRoute; |
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