reject는 Error 객체로 한다 — 문자열로 거부하면 스택 트레이스가 남지 않는다.1

// ❌
Promise.reject('An error occurred');

// ✅
Promise.reject(new Error('An error occurred'));

Footnotes

  1. 14 Linting Rules To Help You Write Asynchronous Code in JavaScript - Maxim Orlov

#56
const formData = new FormData();
const single = document.querySelector('input[type="file"]');
const multiple = document.querySelector('input[type="file"][multiple]');

formData.append('single', single.files[0]);

[...multiple].forEach((file, index) => {
  formData.append(`multiple_${index}`, file);
})

fetch('https://example.com/posts', {
  method: 'POST',
  body: formData,
})
#55
  • 조건에 따라서 브라우저에서 자동으로 발생1
  • OPTIONS 메서드로 요청
  • cloudfront에 OPTIONS 메서드 설정이 안되어 있다면 실패2

Footnotes

  1. 단순 요청(Simple requests)

  2. CloudFront 배포의 캐시 동작이 HTTP 요청에 대한 OPTIONS 메서드를 허용함

#53

Footnotes

  1. XMLHttpRequest가 완전히 성공할때까지 정보를 주기적으로 호출하는 함수

  2. fetch 에서는 ReadableStream, Response 조합으로 구현 가능

  3. axios 에서는 onUploadProgress 콜백(progressEvent)으로 구현

#52
{
  "tailwindcss": "tailwindcss -i ./src/index.css -o ./src/tailwind.css",
  "start": "concurrently \"yarn tailwindcss --watch\"",
  "prebuild": "yarn tailwindcss --minify",
}

create-react-app 구형버젼(+eject)에서 설치할 경우 연관된 부분이 많아서 차라리 cli를 사용하는게 편한 상황. 그런데 concurrently1로 프로세스를 동시에 실행시켜야 되는 부분이 있다.


Footnotes

  1. https://tailwindcss.com/docs/tailwind-cli

#51

Advanced Features: Static HTML Export | Next.js

next export

앱의 HTML 버전을 빌드. .out 디렉토리에 빌드된 페이지 파일을 복사합니다.

#49

How To Maintain A Large Next.js Application — Smashing Magazine

  • TypeScript 사용
  • Lerna , Nx , Rush , Turborepo , yarn workspaces를 사용하여 Mono-Repo 구조 사용
  • Hygen과 같은 코드 생성기를 사용하여 상용구 코드 생성
  • Redux 툴킷을 통해 하위 상용구와 함께 Redux와 같이 잘 설정된 패턴 사용
  • 비동기 데이터를 가져오기 위해 React 쿼리 또는 SWR 사용
  • Husky와 함께 Commitizen 및 Semantic Release 사용
  • UI 구성 요소 시각화를 위해 스토리북 사용
  • 처음부터 유지 관리 가능한 테스트 작성
  • Dependabot을 사용하여 자동으로 패키지 업데이트
  • Production Checklist | Next.js
#48

No, disabling a button is not app logic. - DEV Community

- "idle" 아무 것도 아직 일어나지 않았다.
- "loading" 진행중
- "success" 성공적
- "failure" 오류가 발생했음
#47

Footnotes

  1. React에서 컴포지션의 개념과 “Prop Drilling”을 피하기 위해 React에서 사용하는 방법을 설명.

  2. Headless UI 컴포넌트의 개념을 소개. 헤드리스 UI 컴포넌트가 무엇인지, 기존 UI 컴포넌트와 어떻게 다른지 설명하고, 다양한 프로그래밍 언어와 프레임워크에서 헤드리스 UI 컴포넌트를 구현하는 방법에 대한 예제.

#46

google-optimize


Footnotes

  1. setTimeout, clearTimeout 으로 최적화

  2. gtag 에서도 remove: true값 전달로 해제

  3. variants를 컴포넌트로 전달 받아서 리턴

#38
31 중 29페이지