본문 바로가기
TIL/REACT

PureComponent & props 사용 방법

by koreashowme 2019. 10. 11.

import React, { PureComponentmemo from 'react';



class Try extends PureComponent {

    shouldComponentUpdate(nextPropsnextStatenextContext){

 

    }

    render(){

        const { tryInfo } = this.props;

        return (

            <li>

                <div>{tryInfo.try}</div>

                <div>{tryInfo.result}</div>

            </li>

        )

    }

}

 

// hooks 에서는 PureComponent도 없고, shouldComponentUpdate도 없다.

// memo를 써준다.

 

const Try = memo(({ tryInfo }) => {

    return(

        <li>

            <div>{tryInfo.try}</div>

            <div>{tryInfo.result}</div>

        </li>

    )

})

 

export default Try;

comment