Infinite Re-Renders in Client Component
Answered
Giant panda posted this in #help-forum
Giant pandaOP
Hi, for some reason my component is re-rendering infinitely, and the useEffect() hook is being invoked about twice a second infinitely.
Any ideas why, and how I could resolve this?
Any ideas why, and how I could resolve this?
'use client';
import axios from 'axios';
import { useState, useEffect } from 'react';
export default function Home() {
const [groups, setGroups] = useState(null);
useEffect(() => {
console.log('use effect!');
axios.get('http://localhost:8080/api/groups', { withCredentials: true }).then((res) => {
setGroups(res.data);
});
});
console.log('GROUPS:', groups);
return <main className=""></main>;
}2 Replies
Giant pandaOP
Ah! Thank you so much!