๋ณธ๋ฌธ์œผ๋กœ ๊ฑด๋„ˆ๋›ฐ๊ธฐ

200317

ยท ์•ฝ 12๋ถ„

NPM#

NPM1 - YouTube

Node Package Manager : ์•ฑ์Šคํ† ์–ด์—์„œ ์•ฑ์„ ์„ค์น˜ํ•˜๋Š” ๊ฒƒ์ฒ˜๋Ÿผ NPM์—์„œ ํŒจํ‚ค์ง€๋ฅผ ์„ค์น˜ํ• ์ˆ˜ ์žˆ์Œ.

ํŒจํ‚ค์ง€๋Š” -g (global)์— ์„ค์น˜ํ•  ์ˆ˜๋„ ์žˆ๊ณ , ํ•ด๋‹น ๋””๋ ‰ํ† ๋ฆฌ์˜ ๋ถ€ํ’ˆ์œผ๋กœ์จ ์‚ฌ์šฉํ•˜๋„๋ก์„ค์น˜ํ•  ์ˆ˜ ์žˆ๋‹ค.


๊ฒ€์ƒ‰๊ณผ ์„ค์น˜#

npm

NPM์„ ๊ฒ€์ƒ‰ํ•˜๊ณ  ์„ค์น˜ํ•  ์ˆ˜ ์žˆ๋Š” ์‚ฌ์ดํŠธ


๋งŒ์•ฝ local-web-server ๋ผ๋Š” ํŒจํ‚ค์ง€๋ฅผ ์„ค์น˜ํ•˜๊ณ  ์‹ถ์„ ๋•Œ,

  • npm i local-web-server

  • npm install local-web-server

i๋Š” install์˜ ์•ฝ์ž


์ปดํ“จํ„ฐ์˜ ์ „์—ญ์ ์ธ, ๋…๋ฆฝ์ ์ธ ํ”„๋กœ๊ทธ๋žจ์œผ๋กœ ์„ค์น˜ํ•˜๊ณ  ์‹ถ์„ ๋•Œ,

  • npm install -g local-web-server

g๋Š” global์˜ ์•ฝ์ž

๊ถŒํ•œ์ด ์—†๋‹ค๋ฉด sudo ๋ฅผ ์•ž์— ์ถ”๊ฐ€ํ•œ๋‹ค.


ํŒจํ‚ค์ง€ ๋ชฉ๋ก ๋ณด๊ธฐ์™€ ์—…๋ฐ์ดํŠธ, ์‚ญ์ œ#

ํ˜„์žฌ ๋””๋ ‰ํ† ๋ฆฌ์— ์„ค์น˜๋œ ํŒจํ‚ค์ง€ ๋ณด๊ธฐ

npm list

์ „์—ญ์— ์„ค์น˜๋œ ํŒจํ‚ค์ง€ ๋ณด๊ธฐ

npm list -g

์ „์—ญ์— ์„ค์น˜๋œ ํŒจํ‚ค์ง€ ์ค‘ ์ œ์ผ ์ƒ๋‹จ์— ์žˆ๋Š” ํŒจํ‚ค์ง€๋งŒ ๋ณด๊ธฐ

npm list -g --depth=0

์ „์—ญ์— ์žˆ๋Š” ํŒจํ‚ค์ง€ ์—…๋ฐ์ดํŠธํ•˜๊ธฐ

npm update -g local-web-server

์ „์—ญ์— ์žˆ๋Š” ํŒจํ‚ค์ง€ ์‚ญ์ œํ•˜๊ธฐ

npm uninstall -g local-web-server


๐Ÿ“Œ ๋ฐ”ํ€ด๋ฅผ ๋‹ค์‹œ ๋งŒ๋“ค์ง€ ๋งˆ๋ผ!


React#

React - YouTube

React ์•ฑ ๋งŒ๋“ค๊ธฐ#

  • npm install -g create-react-app - ์ „์—ญ์— ์„ค์น˜ํ•ด์„œ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•.
npm install -g create-react-appmkdir my-appcd my-appcreate-react-app .

  • npx - ์ž„์‹œ๋กœ ํŒจํ‚ค์ง€๋ฅผ ์„ค์น˜ํ•ด์„œ ์‚ฌ์šฉํ•˜๊ณ  ์ง€์šฐ๋Š” ์‹คํ–‰ ๋„๊ตฌ.
npx create-react-app my-appcd my-appnpm start

React ์•ฑ ์‹คํ–‰#

npm run start


์ฝ”๋”ฉํ•˜๊ธฐ#

public ๋””๋ ‰ํ† ๋ฆฌ - static ์ž์›์ด ์œ„์น˜ํ•œ ๊ณณ.#

  • index.html
<div id="root"></div>

์ด root ์•ˆ์— ๋ฆฌ์•กํŠธ ์ปดํฌ๋„ŒํŠธ๋“ค์ด ๋“ค์–ด๊ฐ€๊ฒŒ ๋œ๋‹ค.


src ๋””๋ ‰ํ† ๋ฆฌ - source ์ฝ”๋“œ๊ฐ€ ์žˆ๋Š” ๊ณณ.#

  • index.js
ReactDOM.render(<App />, document.getElementById('root'));

<App /> ์ปดํฌ๋„ŒํŠธ๋ฅผ root ์—˜๋ฆฌ๋จผํŠธ๋กœ ์ „๋‹ฌํ•˜๊ฒŒ๋œ๋‹ค.


  • App.js ํด๋ž˜์Šคํ˜• (ํด๋ž˜์Šคํ˜•๊ณผ ํ•จ์ˆ˜ํ˜• ์ปดํฌ๋„ŒํŠธ๊ฐ€ ์žˆ๋Š”๋ฐ ์ด ๊ฐ•์ขŒ๋Š” ํด๋ž˜์Šคํ˜•์œผ๋กœ์ง„ํ–‰)
import React from 'react';import logo from './logo.svg';import './App.css';
class App extends React.Component {    render() {        return (            <div className="App">                <header className="App-header">                    <img src={logo} className="App-logo" alt="logo" />                    <p>                        Edit <code>src/App.js</code> and save to reload.                    </p>                    <a                        className="App-link"                        href="https://reactjs.org"                        target="_blank"                        rel="noopener noreferrer"                    >                        Learn React                    </a>                </header>            </div>        );    }}
export default App;

โ˜๏ธ ๋ฐ˜๋“œ์‹œ ๋ฆฌ์•กํŠธ๋Š” ๋ฐ˜ํ™˜ํ•  ๋•Œ ํ•˜๋‚˜์˜ ํƒœ๊ทธ๋กœ ๊ฐ์‹ธ์ ธ ์žˆ์–ด์•ผ ํ•œ๋‹ค.


๋ฐฐํฌํ•˜๊ธฐ#

  • npm run build - ๋ฆฌ์•กํŠธ ์•ฑ์„ ๋นŒ๋“œํ•ด์คŒ

  • npx serve -s build - ๋นŒ๋“œํ•œ ์•ฑ์œผ๋กœ ๋กœ์ปฌ ํ˜ธ์ŠคํŒ…


JSX#

๐Ÿ“Œ JSX๋Š” JavaScript๊ฐ€ ์•„๋‹ˆ๋‹ค!

JSX๋กœ ์ž‘์„ฑํ•œ ์ฝ”๋“œ๋Š” create-react-app์— ์˜ํ•ด JavaScript ์ฝ”๋“œ๋กœ ์ปจ๋ฒ„ํŒ… ๋œ๋‹ค.


Hello World!#

import React from 'react';import './App.css';
class App extends React.Component {    render() {        return <div className="App">Hello World!</div>;    }}
export default App;

App class๋Š” ๋ฆฌ์•กํŠธ ์ปดํฌ๋„ŒํŠธ๋ฅผ ํ™•์žฅํ•˜๊ณ  render ๋ผ๋Š” ๋ฉ”์†Œ๋“œ๋ฅผ ๊ฐ€์ง„๋‹ค. (ํ•„์ˆ˜), ํด๋ž˜์Šค ๋‚ด๋ถ€ ๋ฉ”์†Œ๋“œ์—์„œ function ํ‚ค์›Œ๋“œ๋Š” ์ƒ๋žต ๊ฐ€๋Šฅํ•˜๋‹ค. (ES6)


Components ์™€ props#

์ปดํฌ๋„ŒํŠธ๋ฅผ ์—ฌ๋Ÿฌ ๊ฐœ ์‚ฌ์šฉํ•  ๋•Œ ์™„์ „ํžˆ ๋˜‘๊ฐ™์€ ์ปดํฌ๋„ŒํŠธ๋งŒ ์‚ฌ์šฉํ•ด์•ผ ํ•œ๋‹ค๋ฉด, ํ•œ๊ณ„๊ฐ€ ์žˆ์„ ๊ฒƒ์ด๋‹ค. ์ปดํฌ๋„ŒํŠธ๊ฐ€ ํŠน์ • ์†์„ฑ์„ ๊ฐ€์ง์— ๋”ฐ๋ผ ๋ณ€๊ฒฝํ•ด์ค„ ์ˆ˜ ์žˆ๋„๋ก props ๋ฅผ ํ™œ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค.

import React from 'react';import './App.css';
class Subject extends React.Component {    render() {        return (            <header>                <h1>{this.props.title}</h1>                {this.props.sub}            </header>        );    }}
class App extends React.Component {    render() {        return (            <div className="App">                <Subject title="WEB" sub="World Wide Web!" />                <Subject title="React" sub="For UI!" />            </div>        );    }}
export default App;

React Developer Tools#

React Developer Tools


์ปดํฌ๋„ŒํŠธ ํŒŒ์ผ๋กœ ๋ถ„๋ฆฌํ•˜๊ธฐ#

App.js

import React from 'react';import Subject from './components/Subject';import Content from './components/Content';import TOC from './components/TOC';import './App.css';
class App extends React.Component {    render() {        return (            <div className="App">                <Subject title="WEB" sub="World Wide Web!" />                <Subject title="React" sub="For UI!" />                <Content text="HTML is FUN!" />                <TOC />            </div>        );    }}
export default App;

import React from 'react'; - ๋ฆฌ์•กํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด ํ•„์ˆ˜.

ํ•ด๋‹น ์ปดํฌ๋„ŒํŠธ์—์„œ ์‚ฌ์šฉํ•˜๋Š” ๋‹ค๋ฅธ ์ปดํฌ๋„ŒํŠธ๋Š” import ์— ๋ช…์‹œ.

ํ•ด๋‹น ์ปดํฌ๋„ŒํŠธ๊ฐ€ ์™ธ๋ถ€์—์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก export ์— ๋ช…์‹œ.


props ์™€ state#

2020-03-17-200317-image-0

props ๋Š” ์™ธ๋ถ€์—์„œ, ๋‚ด๋ถ€๋กœ ์ „๋‹ฌ. ์™ธ๋ถ€์—์„œ ์‚ฌ์šฉํ•  ์ปดํฌ๋„ŒํŠธ์— ์†์„ฑ์— ๊ธฐ์ž…ํ•˜๋ฉด ๋‚ด๋ถ€ ์ปดํฌ๋„ŒํŠธ์—์„œ props ๋กœ ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ์Œ. ์‚ฌ์šฉํ•˜๋Š” ์ž…์žฅ์—์„œ ์กฐ์ž‘.

state ๋Š” ๋‚ด๋ถ€์˜ ์ƒํƒœ ๊ฐ’.


App.js

import React from 'react';import Subject from './components/Subject';import TOC from './components/TOC';import Content from './components/Content';import './App.css';
class App extends React.Component {    constructor(props) {        super(props);        this.state = {            subject: {title: 'WEB', sub: 'World Wide Web!'},        };    }    render() {        return (            <div className="App">                <Subject                    title={this.state.subject.title}                    sub={this.state.subject.sub}                />                <Subject title="React" sub="For UI!" />                <TOC />                <Content text="HTML is FUN!" />            </div>        );    }}
export default App;

constructor : ์ปดํฌ๋„ŒํŠธ๊ฐ€ ์‹คํ–‰๋  ๋•Œ ๊ฐ€์žฅ ๋จผ์ € ์‹คํ–‰๋˜๋Š” ํ•จ์ˆ˜ ( state ๊ฐ’์„ ์ดˆ๊ธฐํ™”)

ํ•ด๋‹น ๊ฐ์ฒด ์•ˆ์—์„œ { this.state.subject.title } ์œผ๋กœ ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ์Œ.


TOC ๊ฐœ์„ #

TOC.js

import React from 'react';
class TOC extends React.Component {    render() {        var lists = [];        var data = this.props.data;        var i = 0;
        while (i < data.length) {            lists.push(                <li key={data[i].id}>                    <a href={'/content/' + data[i].id}>{data[i].title}</a>                </li>,            );            i = i + 1;        }
        return (            <nav>                <ul>{lists}</ul>            </nav>        );    }}
export default TOC;

TOC.js ์—์„œ ์™ธ๋ถ€์—์„œ data (๊ฐ์ฒด๊ฐ€ ๋‹ด๊ธด ๋ฆฌ์ŠคํŠธ)๋ฅผ props ๋กœ ์ „๋‹ฌ๋ฐ›๊ณ , ํ•ด๋‹น๋ฆฌ์ŠคํŠธ์˜ ์š”์†Œ๋“ค์„ ์ˆœ์ฐจ์ ์œผ๋กœ lists ์— ๋‹ด์•„ ์ถœ๋ ฅํ•˜๊ฒŒ ๋ฐ”๊พผ๋‹ค.

์ด ๋•Œ ์—ฌ๋Ÿฌ ๊ฐœ์˜ ๋ชฉ๋ก์€ key ๋ฅผ ๊ฐ€์ ธ์•ผํ•œ๋‹ค. key={data[i].id} ๊ฐ€ ํ•„์ˆ˜.

ํ‚ค๋ฅผ ๊ธฐ์ž…ํ•˜์ง€ ์•Š์„ ๊ฒฝ์šฐ.

2020-03-17-200317-image-1


App.js

import React from 'react';import Subject from './components/Subject';import TOC from './components/TOC';import Content from './components/Content';import './App.css';
class App extends React.Component {    constructor(props) {        super(props);        this.state = {            subject: {title: 'WEB', sub: 'World Wide Web!'},            contents: [                {id: 1, title: 'HTML', desc: 'HTML is for information'},                {id: 2, title: 'CSS', desc: 'CSS is for Design'},                {id: 3, title: 'JavaScript', desc: 'JavaScript is for Interactive'},            ],        };    }    render() {        return (            <div className="App">                <Subject                    title={this.state.subject.title}                    sub={this.state.subject.sub}                />                <TOC data={this.state.contents} />                <Content text="HTML is FUN!" />            </div>        );    }}
export default App;

์ด๋ ‡๊ฒŒ ์™ธ๋ถ€์—์„œ Contents ๋ฅผ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ๋‹ค.


์ด๋ฒคํŠธ state , props , render() ํ•จ์ˆ˜#

React ์—์„œ๋Š” props ๋˜๋Š” state ์˜ ๊ฐ’์ด ๋ณ€๊ฒฝ๋˜์—ˆ์„ ๋•Œ render() ํ•จ์ˆ˜๊ฐ€ ํ˜ธ์ถœ๋˜๋„๋ก ์•ฝ์†๋˜์–ด ์žˆ๋‹ค. โ†’ ํ™”๋ฉด์ด ๋‹ค์‹œ ๊ทธ๋ ค์ง„๋‹ค.


๋™์ ์œผ๋กœ ๋ณ€์ˆ˜ ์ œ์–ด#

Subject.title ์„ ํด๋ฆญํ–ˆ์„ ๋•Œ, this.state.mode ๋ณ€์ˆ˜๋ฅผ ๋ณ€๊ฒฝํ•˜๊ณ  ์‹ถ๋‹ค. ์ด ๋•Œ Subject.title ์€ <a> ํƒœ๊ทธ๋กœ ๊ฐ์‹ธ์ ธ ์žˆ๋‹ค.

onClick ์†์„ฑ์œผ๋กœ ํด๋ฆญํ–ˆ์„ ๋•Œ ์‹คํ–‰ํ•  ํ•จ์ˆ˜(์ด๋ฒคํŠธ ํ•ธ๋“ค๋Ÿฌ)๋ฅผ ์ •์˜ํ•  ์ˆ˜ ์žˆ๋‹ค.

๊ทธ๋Ÿฐ๋ฐ onClick ์ด ๋ฐœ์ƒํ–ˆ์„ ๋•Œ, ํ™”๋ฉด์ด ์ƒˆ๋กœ๊ณ ์นจ ๋œ๋‹ค. <a> ํƒœ๊ทธ์˜ ๊ธฐ๋ณธ ๋™์ž‘ ๋ฐฉ๋ฒ•์ด๊ธฐ ๋•Œ๋ฌธ.


...
<h1><a href="/" onClick={function(e){  console.log(e);    // debugger;  e.preventDefault();}}>{this.state.subject.title}</a></h1>
...

โ˜๏ธ debugger; ๋ฅผ ์‚ฝ์ž…ํ•˜๊ณ  ์‹คํ–‰ํ•˜๋ฉด ํ•ด๋‹น ์œ„์น˜์—์„œ ๋ฉˆ์ถฐ์ง€๊ณ  ๊ฐœ๋ฐœ์ž๋„๊ตฌ์—์„œ ํ•ด๋‹น์œ„์น˜์˜ ์†Œ์Šค๋ฅผ ๋ณผ ์ˆ˜ ์žˆ์Œ


์ด๋ฒคํŠธ๊ฐ€ ๋ฐœ์ƒํ•œ ํƒœ๊ทธ์˜ ๊ธฐ๋ณธ์ ์ธ ๋™์ž‘๋ฐฉ๋ฒ•์„ ๋ชปํ•˜๊ฒŒ ๋ง‰๋Š” ๊ฒƒ์ด event ๊ฐ์ฒด์˜ preventDefault() ๋ผ๋Š” ํ•จ์ˆ˜์ด๋‹ค. ์ด๋ฅผ ํ†ตํ•ด ์ƒˆ๋กœ๊ณ ์นจ๋˜๋Š” ํ˜„์ƒ์„ ๋ง‰์„ ์ˆ˜ ์žˆ๋‹ค.


state ๋ฅผ ๋ณ€๊ฒฝํ•˜๊ณ  ์‹ถ์„ ๋•Œ.

return (    <div className="App">        <header>            <h1>                <a                    href="/"                    onClick={function (e) {                        e.preventDefault();                        this.setState({                            mode: 'welcome',                        });                    }.bind(this)}                >                    {this.state.subject.title}                </a>            </h1>            {this.state.subject.sub}        </header>        <TOC data={this.state.contents} />        <Content title={_title} desc={_desc} />    </div>);
  • ์ด๋ฒคํŠธ๊ฐ€ ์‹คํ–‰๋์„ ๋•Œ ์‹คํ–‰๋˜๋Š” function ๋‚ด๋ถ€์— this ์˜ ๊ฐ’์ด ์•„๋ฌด๊ฒƒ๋„ ์„ธํŒ…๋˜์–ด์žˆ์ง€ ์•Š๋‹ค. โ†’ this ๋ฐ”์ธ๋”ฉ ์‚ฌ์šฉํ•ด์•ผํ•จ. ํ•จ์ˆ˜ ์•ˆ์˜ this ๋ฅผ ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ๋„ฃ์€ ๊ฐ’์œผ๋กœ ์„ค์ •ํ•จ. ( this = App )

  • state ๋ฅผ ๋™์ ์œผ๋กœ ๋ณ€๊ฒฝํ•  ๋• setState ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•จ


React์—์„œ ๊ฐ์ฒด ๋˜๋Š” ๋ฐฐ์—ด state ๋ณ€๊ฒฝ#

React์—์„œ๋Š” ์ปดํฌ๋„ŒํŠธ์˜ state ๊ฐ€ ๋ณ€๊ฒฝ๋  ๋•Œ๋งˆ๋‹ค ํ•ด๋‹น ์ปดํฌ๋„ŒํŠธ render ํ•จ์ˆ˜์™€ ํ•˜์œ„ ์ปดํฌ๋„ŒํŠธ์˜ render ํ•จ์ˆ˜๋ฅผ ์‹คํ–‰ํ•ด reload ํ•˜๊ฒŒ ๋œ๋‹ค.

๋”ฐ๋ผ์„œ ํ•˜์œ„ ์ปดํฌ๋„ŒํŠธ์—๋Š” ๋ณ€๊ฒฝ๋˜๋Š” ๊ฒƒ์ด ์—†๋‹ค๋ฉด ๋น„ํšจ์œจ์ ์ผ ์ˆ˜ ์žˆ๋‹ค.

์ด๋ฅผ ์œ„ํ•ด React.Component ์˜ shouldComponentUpdate ํ•จ์ˆ˜๊ฐ€ ์žˆ๋‹ค.

shouldComponentUpdate ๋Š” newProps ์™€ newState ๋ผ๋Š” ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ๊ฐ€์ง„๋‹ค. ์—ฌ๊ธฐ์„œ newProps ๋Š” ์ปดํฌ๋„ŒํŠธ์˜ ๋ฐ”๋€ props ๊ฐ’์„ ๋งํ•œ๋‹ค.

newProps ์™€ ์ด์ „ ๊ฐ’์„ ๋‚˜ํƒ€๋‚ด๋Š” this.props.data ๋ฅผ ์ด์šฉํ•ด props ๊ฐ€ ๋ฐ”๋€Œ์—ˆ์„๋•Œ๋งŒ ํ•ด๋‹น ์ปดํฌ๋„ŒํŠธ์˜ render ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ•˜๊ฒŒ ํ•  ์ˆ˜ ์žˆ๋‹ค. (๋‘˜์ด ๊ฐ™์œผ๋ฉด false ๋ฆฌํ„ดํ•˜๊ณ  ๋‘˜์ด ๋‹ค๋ฅด๋ฉด true ๋ฅผ ๋ฆฌํ„ดํ•จ์œผ๋กœ ๊ฐ€๋Šฅ)

๊ทธ๋Ÿฐ๋ฐ ๋งŒ์•ฝ state ์— ๊ฐ์ฒด ๋˜๋Š” ๋ฐฐ์—ด์ด ์žˆ์„ ๊ฒฝ์šฐ์—, ๊ฐ์ฒด๋‚˜ ๋ฐฐ์—ด์˜ ์›๋ณธ์„ ๋ณ€๊ฒฝํ•˜๋Š” ํ•จ์ˆ˜๋ฅผ ํ†ตํ•ด state ๋ฅผ ์—…๋ฐ์ดํŠธํ•˜๊ฒŒ ๋˜๋ฉด(์˜ˆ๋ฅผ ๋“ค์–ด, ๋ฐฐ์—ด์˜ push ํ•จ์ˆ˜๋Š” ์›๋ณธ์— ๋ฐ์ดํ„ฐ๋ฅผ ์ถ”๊ฐ€ํ•œ๋‹ค.) ์›๋ณธ์ด ์ˆ˜์ •๋˜์—ˆ๊ธฐ ๋•Œ๋ฌธ์— newProps ์™€ this.props.data ๋Š” ๊ฐ™์„ ์ˆ˜๋ฐ–์— ์—†๊ณ , ๋”ฐ๋ผ์„œ shouldComponentUpdate ํ•จ์ˆ˜๋ฅผ ํ†ตํ•œ ์กฐ์ž‘์ด ๋ถˆ๊ฐ€๋Šฅํ•ด์ง€๊ณ  ์ด๋Š” ์„ฑ๋Šฅ ๊ฐœ์„ ์„ ๋ถˆ๊ฐ€๋Šฅํ•˜๊ฒŒ ๋งŒ๋“ค๊ฒŒ ๋œ๋‹ค.

๋”ฐ๋ผ์„œ ๋ฐฐ์—ด์—์„œ๋Š” push ํ•จ์ˆ˜ ๋Œ€์‹  concat , ๊ฐ์ฒด์—์„œ๋Š” Object.assign ํ•จ์ˆ˜ ๋“ฑ์œผ๋กœ ์ƒˆ๋กœ์šด ๋ฐฐ์—ด์ด๋‚˜ ๊ฐ์ฒด๋กœ state ๋ฅผ ๋ฐ”๊ฟ”์ฃผ๋Š” ๊ฒƒ์œผ๋กœ shouldComponentUpdate ํ•จ์ˆ˜๋ฅผ ํ†ตํ•œ ์กฐ์ž‘์„ ๊ฐ€๋Šฅํ•˜๊ฒŒ ํ•  ์ˆ˜ ์žˆ๋‹ค.