분류 전체보기
-
[Vite] 절대경로 설정프로그래밍/React 2024. 1. 3. 14:14
Vite + Typescript 를 사용한 프로젝트에서 절대경로를 설정하는 방법 tsconfg.json 과 vite.config.json 모두 고쳐줘야한다. >tsconfig.json { "compilerOptions": { "baseUrl": "src", ... "path": { "pages/*": ["pages/*"], "components/*": ["components/*"], } } 아래의 설정을 하지 않아서 경로를 제대로 찾지 못하는 에러가 발생했었음. import { defineConfig } from "vite"; import react from "@vitejs/plugin-react-swc"; // https://vitejs.dev/config/ export default defineCon..
-
[CS Study] 스코프, 스코프체인프로그래밍 언어/JavaScript 2024. 1. 2. 09:18
개요 스코프 스코프 체인 스코프 식별자의 유효범위로 변수에 접근할 수 있는 범위를 말하며 참조 대상 식별자를 찾아내기 위한 규칙이다. var x = "global"; function foo() { var x = "function scope"; console.log(x); } foo(); // function scope console.log(x); // global 위와 같은 코드에서 전역변수인 x는 어디서든 참조할 수 있지만 foo() 내부에 선언된 지역변수 x는 foo() 내부에서만 참조할 수 있다. 이러한 규칙을 스코프라고 한다. 스코프가 필요한 이유) 의도치 않은 변수 값의 변조를 방지 (변수명의 충돌) 효율적인 메모리 관리 (코드 블럭 안의 참조값들은 코드가 실행될 때만 메모리에 할당 됨) 전역변..
-
[React] useState의 동작원리프로그래밍/React 2023. 12. 16. 11:36
개요 기본개념 useState 동작 원리 헷갈리는 useState 결론 React에서 많이 사용되는 useState 왜 const로 선언이 되고 어떻게 변화를 시키는지 알아보자!! 기본 개념 Functional Component에서 상태) 불변성의 특징을 통해 사용하는 값을 예측 가능하게 만들어준다. 함수의 반환 값으로 컴포넌트가 나타나고 컴포넌트가 가진 값, 클로저 등의 정보는 기본적으로 변하지 않는다. Class Component는 this가 바인딩 된 것, 내부 상태값의 변화 등의 문제로 메서드 실행시점의 값을 예측하는 것이 쉽지 않다. 리랜더링이 필요한 시점에서 새롭게 호출을 하여 새로 만들어버린다. 초기 시점에 불변성을 활용하는 부분에 어려움이 있어 Class Component가 많이 사용되고 ..
-
[CS Study] 동기, 비동기처리네트워크/CS Study 2023. 12. 15. 21:46
개요 Javascript의 동작 방식 동기, 비동기 방식 Javascript의 비동기처리 Javascript 동작 방식 Javascript는 함수를 호출했을 때 어떤 동작을 실행하는지 알아보자! Javascript엔진은 단 하나의 실행 컨텍스트 스택을 갖는다.(한 번에 하나의 함수만 실행 가능, 싱글 스레드 방식) 자바스크립트 엔진이 함수 코드를 평가하고 함수 실행 컨텍스트를 생성한다. 생성된 실행 컨텍스트는 실행 컨텍스트 스택(Callstack)에 push되고 함수 코드가 실행된다. 실행이 종료되면 함수 실행 컨텍스트가 컨텍스트 스택(Callstack)에서 pop으로 제거된다. 이러한 자바스크립트 엔진이 시간이 걸리는 작업을 마주하게 되면 블로킹(작업 중단)이 발생한다. 테스크 큐와 이벤트 루프 싱글 ..