CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/next/lib/share/counter.ts
Views: 687
1
/*
2
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
import { useEffect } from "react";
7
import { useRouter } from "next/router";
8
9
export default function useCounter(id: string | undefined) {
10
// call API to increment the counter
11
const router = useRouter();
12
useEffect(() => {
13
if (id != null) {
14
fetch(`${router.basePath}/api/share/public_paths/counter/${id}`);
15
}
16
}, [id]);
17
}
18
19