REACT

REACT_Constructor()

ssmm95 2024. 9. 20. 13:05

 

 

- R005_LifeCycleEx.js

import React, {Component} from 'react';

class R005_LifeCycleEx extends Component {
    constructor(props) {
        super(props);
        this.state = {};
        console.log('1. constructor Call');
    }
    render(){
        console.log('3. render Call');
        return(<h2>[THIS IS CONSTRUCTOR FUNCTION_05]</h2>)
    }
}
export default R005_LifeCycleEx;

 

- App.js

import React from 'react';
import './App.css'; 
//App.css가 App.js 보다 더 한 단계 상위 폴더에 있다면  
//'./..App.css'

import LifeCycleEx from './R005_LifeCycleEx.js';

function App() {
  return (
    <div>
      <h1>Start React 200!</h1>
      <p>css 적용하기</p>
      <LifeCycleEx prop_value = 'FromApp.js'/>
    </div>
  );
}

export default App;

 

결과

'REACT' 카테고리의 다른 글

REACT_Map()으로 Element 반환하기  (0) 2024.09.23
REACT_Hook  (0) 2024.09.23
REACT_render()  (0) 2024.09.20
REACT_생명주기함수 변경_shouldComponentUpdate()(  (0) 2024.09.20
REACT_템플릿 문자열  (0) 2024.09.20