mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2025-04-27 15:16:21 -04:00
fix component effects
This commit is contained in:
parent
65d413ca8c
commit
7fbdf16573
@ -10,7 +10,7 @@ const Counter = (props) => {
|
|||||||
|
|
||||||
// start fetching hits from API once slug is set
|
// start fetching hits from API once slug is set
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return fetch(`/api/hits/?slug=${encodeURIComponent(props.slug)}`)
|
fetch(`/api/hits/?slug=${encodeURIComponent(props.slug)}`)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((data) => setHits(data.hits || 0));
|
.then((data) => setHits(data.hits || 0));
|
||||||
}, [props.slug]);
|
}, [props.slug]);
|
||||||
|
@ -12,7 +12,7 @@ const RepositoryGrid = () => {
|
|||||||
// start fetching repos from API immediately
|
// start fetching repos from API immediately
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// API endpoint (sort by stars, limit to 12)
|
// API endpoint (sort by stars, limit to 12)
|
||||||
return fetch("/api/projects/?top&limit=12")
|
fetch("/api/projects/?top&limit=12")
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((data) => setRepos(data || []));
|
.then((data) => setRepos(data || []));
|
||||||
}, []);
|
}, []);
|
||||||
|
@ -11,7 +11,7 @@ const ThemeToggle = () => {
|
|||||||
const [dark, setDark] = useState(isDark());
|
const [dark, setDark] = useState(isDark());
|
||||||
const [saved, setSaved] = useState(!!getDarkPref());
|
const [saved, setSaved] = useState(!!getDarkPref());
|
||||||
|
|
||||||
// real-time switching between modes based on system if preference isn't set (and it's supported by OS/browser)
|
// real-time switching between modes based on user's system if preference isn't set (and it's supported by OS/browser)
|
||||||
const matchCallback = useCallback((e) => setDark(e.matches), []);
|
const matchCallback = useCallback((e) => setDark(e.matches), []);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user