app
여기 아래 Header와 관련 컴포넌트를 넣을 디렉토리
context
import { createContext, useContext, useState } from "react";
type AuthContextValue = {
isLoggedIn: boolean;
};
const initialValue: AuthContextValue = {
isLoggedIn: false,
};
const AuthContext = createContext<AuthContextValue>(initialValue);
export const useAuth = () => useContext(AuthContext);
export function AuthProvider({ children }: { children: React.ReactNode }) {
const [isLoggedIn, setIsLoggedIn] = useState<boolean>(false);
const value: AuthContextValue = { isLoggedIn };
return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>;
}
modal
프로바이더스를
redux
import { createSlice } from "@reduxjs/toolkit";
type UtilsStore = {
modal: React.ReactElement | null; //컴포넌트 x 엘리먼트임
};
const initialState = {
modal: null,
};
const utilsSlice = createSlice({
initialState,
name: "utils",
reducers: {
setModal: (
state,
action: { type: string; payload: UtilsStore["modal"] }
) => {
state.modal = action.payload;
},
},
});
리액트 query
<QueryClientProvider client={}>
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
}
서버사이드 렌더링
이게 클라이언트 사이드보다 검색에서 유리함.
서버사이드에서 그리고 보내주는 방식. 넥스트는 이걸 그 안에 있는 컴포넌트 구조로 사용할 수 있게해서 좋아.
use client 를 지워주고 작성.
로그인 로그아웃