본문 바로가기

반응형

JavaScript/React

(5)
참고하면 좋은 사이트 보호되어 있는 글입니다.
부모에서 자식, 자식에서 부모로 Prop 전달하기 1. 부모에서 자식으로 Prop 전달하기 부모 import { Component } from 'react'; // 부모 class App extends Component { render ( ); } 자식 - 클래스 import { Component } from 'react'; //자식 class Searchbar extends Component { render ( {this.props.text} ); } 자식 - 함수 import React from 'react'; const Searchbar = (props) => { return ( {props.text} ); } 2. 자식에서 부모로 Props 전달하기 부모 import { Component } from 'react'; class App extend..
React Router 경로가 변경되어도 React Redux connect 에 속한 render 는 호출되지 않는 다. 보호되어 있는 글입니다.
[Spread Operator] 배열에 특정한 인덱스의 아이템 교체 let arr = [1,2,3,4,5]; 이 배열의 2번째 인덱스를 10으로 교환해보자. 아래와 같이 [1,2,10,4,5]; 해결 const index = 2; const newVal = 10; arr = [ ...arr.slice(0, index), newVal, ...arr.slice(index + 1) ] 리액트 setState에서의 사용 예시 const newfile = { s3KeyThumbnail: 'blahblah.jpg'; size: 1024, ext: 'jpg' } this.setState(state => ({ ...state, files: [ ...state.files.slice(0, index), newFile, ...state.files.slice(index + 1) ] })); ..
React 보면 좋을 사이트 튜토리얼: React 시작하기 - https://reactjs-kr.firebaseapp.com/tutorial/tutorial.html#what-were-building 리액트 기초 입문 프로젝트 (투두리스트 만들기) - https://velopert.com/3480 React.JS 강좌 목록 - https://velopert.com/reactjs-tutorials

반응형