Skip to content

Commit

Permalink
fix: invalid react hook call
Browse files Browse the repository at this point in the history
  • Loading branch information
wibus-wee committed May 1, 2023
1 parent 4ebc612 commit 57ebe9e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/pages/Home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export const Home: BasicPage = () => {
comments,
pages,
} = useHomeAggregateData();

useEffect(() => {
if (
friendsPending &&
Expand Down
16 changes: 8 additions & 8 deletions src/pages/Register/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ export const RegisterPage: BasicPage = () => {
const formRef = useRef<HTMLFormElement>(null);
const appSnapshot = useSnapshot(app);

const { error } = useSWR("/user/master/info");
if (!error) {
toast.error("已注册,正在前往登录页面");
navigate(jump("/login"));
app.showSidebar = false;
}

useEffect(() => {
if (appSnapshot.authenticated) {
toast.success("已登录,正在前往仪表盘")
toast.success("已登录,正在前往仪表盘");
navigate(jump("/dashboard"));
return;
}
const { error } = useSWR("/user/master/info");
if (!error) {
toast.error("已注册,正在前往登录页面")
navigate(jump("/login"));
return;
}
app.showSidebar = false;
}, []);

function handleSubmit(e: React.FormEvent<HTMLFormElement>) {
Expand Down
4 changes: 2 additions & 2 deletions src/utils/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const apiClient = ofetch.create({
});

export const fetch = (url: RequestInfo) => {
const getToken = getCookie("token");
const headers = { Authorization: `Bearer ${getToken}`, token: getToken || "" };
const getToken = getCookie("token") || "";
const headers = { Authorization: `Bearer ${getToken}`, token: getToken };
return apiClient(url, { headers });
};

0 comments on commit 57ebe9e

Please sign in to comment.