Let's add all the .vs/ files in the .gitignore so others don't have to pull this down
nit: Let's keep component names in TitleCase!
Delete this, there isn't a package.json at the very root level
Always use const when declaring variables, unless you have to perform direct mutation (which is rare), then use let
Good job putting components in diff files, makes the main Analytics file cleaner!
The intention was to declare the viewCount and clickCount variables at the start of the component, and then mutate them in the fetch function inside the useEffect (getting the actual view/click count from the returned json). I can't seem to directly declare const variables in useEffect and then use them. Should I use let or is there another way around this? Thanks!
Hmmm so this approach wouldn't work. Direct mutation is generally avoided in React because it's most often a sign of bad practice. Since React only re-renders when state is changed, during the initial render, you will see 0 views and 0 clicks.
When you mutate viewCount and clickCount, even though you've updated the variables, it won't trigger a re-render, so you'll still see 0 views and 0 clicks.
Instead make both into state variables by using useState and use their appropriate setState functions on lines 14-16