next.js

나 안해·2023년 3월 21일
0

saga(서사구조, 화면쪽에서의 인공지능)

  • 말로 전한다 → 말하기 패턴
  • 대기 상태에 있다가 인식해야 될 입력이 발생하면 작동(인식되지 않는건 노이즈)

    MSA끼리 이벤트(상태의 변화)를 주고받으며 작업이 이뤄지는 패턴

트랜잭션의 관리주체가 DBMS(SQL)이 아닌 Application(fastapi)에 있다

  • 패키징된 입력을 보내서 자료를 찾는 기존의 개념을 지나서 해당 기억을 가지고 입력되는대로 인식한다고 생각하면 좋다
  • 트랜젝션 문제 때문에 어렵다
    • 트랜젝션 : DB의 상태를 변화시키기 위한 단위
  • partition / slice
    • 전체와 부분이 다르지 않으면 슬라이스
리듀서매핑필터
축소전체하나만
해당코드는 user에서 reducers에 입력된 상태가 생기면 

const userSlice = createSlice({
    name: 'userSlice',
    initialState,
    reducers: {
        joinRequest(state:IUserState, _payload){    #const joinRequest=()=>{}를 생략한 형태
            state.status = 'loading'
        },
        joinSuccess(state:IUserState, {payload}){
            state.status = 'idle'
            state.data = [...state.data, payload] # 오버로딩 상태로 '...state.data'가 없으면 이전 데이터를 날리게 된다
        }
    }
})

///Modules/users/userAPI.ts에 Modules/users/index.ts의 인터페이스 타입을 추가
  • payload와 payload의 차이는 가 있으면 보안이 필요하고 이미 아는 정보 _가 없는건 보안이 필요없는 요소에 사용하고 오픈된 상태에서 사용해야 한다
    참고

db 관련

컴포넌트에서 아래 같은 코드가 없으면 해당 스키마는 db에 적용되지 않는다

{...register("스키마", { 
  required: true, 
  maxLength: {
      value: 20,
      message: "20자 이하로 입력해주세요"
  }

create next js typescript app

https://nextjs.org/docs/api-reference/create-next-app

  • 터미널에서 npx create-next-app@latest 입력으로 앱 생성
  • vs코드로 실행 후 터미널에서 아래 명령어 순서대로 입력
    • npm install --location=global
    • npm install yarn
    • yarn add next

Error

The default export is not a React Component in page:"/'

원인

export default가 없을 때 발생하는 에러

4. WrappedApp created new store with withRedux(MyApp) { initialState: undefined, initialStateFromGSPorGSSR: undefined }

상황

링크 설정하면 서 경로를 잘못 쓴 경우 발생

yarn build나 yarn dev 실행시 실행이 안되는 경우

원인

github로 협업시 next가 없을 때 발생하는 문제

해결

npm install node나 yarn add node를 실행

307

next에서 module의 인터페이스 타입과 fastapi의 schema는 같은 이름으로 통일하는게 편하다

The above error occurred in task watchJoin
created by rootSaga
Tasks cancelled due to error:
rootSaga

해결

saga에 있던
alert(" %%% export function* watchJoin()")
를 지웠다

Cannot access before initialization

원인
1. export default를 object보다 위에 둔 경우

sqlalchemy.exc.IntegrityError: (1062,

원인

DB에서 primary_key가 중복된 경우 발생하는 에러

Error: Text content does not match server-rendered HTML

원인

렌더링된 HTML(SSR, ISR 등)이 업데이트되지만 페이지 로드 후 React 코드는 업데이트되지 않아서 발생

해결

Error: Hydration failed because the initial UI does not match what was rendered on the server.

Error: There was an error while hydrating. Because the error happened outside of a Suspense boundary, the entire root will switch to client rendering.


etc

  • modules는 테이블명과 일치시켜야 한다

0개의 댓글