react
-
18. React [리액트 숙련 주차] REDUX 리덕스를 쓰는 이유, Reducer, Dispatch, Action객체 용어 정리, 흐름의 이해Java Script & Type Script 2023. 1. 2. 17:32
스파르타코딩클럽 리액트 숙련강의 7강까지의 내용이다........ 8강 넘어가기 전에 정확히 파악해야 8강에서 헤매지 않을 것이라하셔서 9강까지 먼저 보는게 목표였는데 중간 복습을 한번 하려한다.. Redux 쓰는 이유 모든 component가 props 없이도state를 직접 꺼내서 쓸 수 있기 때문에 용이하다. 부모에서 자식방향으로만 프롭스 전달이 가능하다는 불편함을 보완한 것이 리덕스이다. 2~99번의 불필요한 과정이 props drilling이다. Global state 전역상태 : 컴포넌트가 아닌, 중앙 state관리소에서 state들을 생성, 관리한다. 어떤 컴포넌트에서 state가 필요하다면 컴포넌트가 어디에 위치하고있든 상관 없이 state를 불러와 사용 가능. Local state 지역상..
-
15. React [리액트 애플코딩] 컴포넌트생성, 동적인 UI만들기Java Script & Type Script 2022. 12. 29. 00:19
컴포넌트 만들기 1. function을 다른 함수 바깥에 만들고 대문자로 시작하는 컴포넌트를 작명한다. 2. return() 소괄호 안에 표현할 html을 담는다. 여기서, 태그는 두개 이상 병렬할 수 없다. return ( "Hello" "How are you?" ) 이게 안된다는 거다. return 내에 꼭 html을 병렬로 두개 이상 기입하고싶다면, 이렇게 아무 의미 없는 를 대신해서 를 사용할 수 있다. 이를 Fragment문법이라고 한다. 3. 컴포넌트를 표현하기 원하는 위치에 을 입력 (위치는 함수 밖이어야한다) 그리고 보통은 이렇게 쓰지만 이렇게 하나에 다 담고 닫아도 된다. 컴포넌트 어떨 때 쓰면 좋을까 컴포넌트의 단점은 state를 가져다쓸 때 문제가 생긴다는거다. A함수에 있던 변수는 ..