Code Monkey home page Code Monkey logo

react_test's Introduction

생활코딩 React

Bulid / Start

  1. npm run start --> 다양한 기능을 포함하고 있지만 용량이 크다. 개발 시 사용
  2. npm run build --> 사용된 기능만 포함하여 용량이 작다. 배포 시 사용

Component

  • 컴포넌트 생산 시 하나의 최상위 태그만 사용

JSX

{this.props.title}

props

### 컴포넌트 태그의 속성으로 데이터 등록
    <Subject title="WEB"> </Subject>

### 컴포너틑 클래스에서 JSX로 데이터 출력

React Developer Tool

리액트로 작성된 페이지의 컴포넌트 확인, 수정 가능

Constructor

컴포넌트 사용시 가장먼저 실행되어 초기화 담당

State

외부에서 스테이트 값을 알 수 없다. (은닉성)
스테이트의 값을 컴포넌트의 props의 값으로 사용

Tag Option

* onClick
* preventDefault
* onChangePage - 클릭 시 호출할 함수 등록
* onSubmit - submit 시 작동

debugger

디버거 실행 시 동작 정지

bind

* render안의 함수 안에서 this 호출 시 this는 window or undefined
* this.function_name.bind(this); 사용 시 함수의 this는 bind의 값
* 두 번째 인자를 첫 번째 매개변수의 값으로 전달

setState

동적으로 state 변경 시 setState를 사용해야지 변경 후 리로딩

data-name

e.target.dataset.name 으로 접근

Props VS State

### Props
    * props are read only
    * props can no be modified

### State
    * state changes can be asynchronous
    * state can be modified using this.setState

데이터 전달

### 상위 컴포넌트 -> 하위 컴포넌트
    * props로 데이터 전달

### 하위 컴포넌트 -> 상위 컴포넌트
1. 상위 컴포넌트에 onChangePage로 함수 등록 (이벤트 구현)
2. 하위 컴포넌트에서 onChangePage 호출 (매개변수 전달) / setState로 상탠 변경

contributions test

State push

this.state.push(props) ==> this.setState({content: this.state.content})
var content = this.state.concat(props) ==> this.setState({content:content})

push VS concat

array.push(val) = 원본을 수정
array.concat(val) : 추가한 배열을 생성 
* 가급적 원본을 변경하지 않고 새로운 값을 생성할 것!!! ===> shouldComponentUpdate를 통해 this와 new 비교

shouldComponentUpdate

return true; ==> render() 호출
return false; ==> render() 호출 X
매개변수 newProps, newState 

immutable.js (?)

JS

Array.from(x) : 배열을 각 요소마다 x를 실행 / 배열 복제
Object.assign(new, target) : 객체 복제

Array.from(ele)

배열 복제

CRUD

###delete ==> _contents.splice(i,1);

과제

### immutable
    immutable.js
### router
    server
### npm run eject
### redux
### react server side rendering

react_test's People

Contributors

mnj190 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.