React Hook "useEffect" is called conditionally. React Hooks must be called in the exact same order in every component render. Did you accidentally call a React Hook after an early return?
만약 조건부로 Hook을 쓰고 싶다면 Hook 내부에 선언해야 한다.
useEffect(() => {
// hooks 최상위 선언부
const getuserprofile = async () => {
await GroupService.getGroupOwn()
.then((res) => res.data.response)
.then((body) => {
setOwndata([...owndata, ...body]);
setIsclick(body[0]);
});
};
if (owndata.length === 0) {
getuserprofile();
}
}, []);
훅을 일반적인 자바스크립트 함수에서 호출하면 안된다. 리액트 함수 컴포넌트나 커스텀 훅에서는 호출이 가능하다.