<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>ONCE_DEVELOPER</title>
        <link>https://velog.io/</link>
        <description>위대한 포부가 위대한 개발자를 만듭니다.</description>
        <lastBuildDate>Sat, 03 Jul 2021 04:36:54 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <image>
            <title>ONCE_DEVELOPER</title>
            <url>https://images.velog.io/images/once_developer/profile/c57e7b72-febb-43fe-8ef5-fab24893349c/social.jpeg</url>
            <link>https://velog.io/</link>
        </image>
        <copyright>Copyright (C) 2019. ONCE_DEVELOPER. All rights reserved.</copyright>
        <atom:link href="https://v2.velog.io/rss/once_developer" rel="self" type="application/rss+xml"/>
        <item>
            <title><![CDATA[7장. Class형 컴포넌트 Project]]></title>
            <link>https://velog.io/@once_developer/6%EC%9E%A5.-Class%ED%98%95-%EC%BB%B4%ED%8F%AC%EB%84%8C%ED%8A%B8-Project</link>
            <guid>https://velog.io/@once_developer/6%EC%9E%A5.-Class%ED%98%95-%EC%BB%B4%ED%8F%AC%EB%84%8C%ED%8A%B8-Project</guid>
            <pubDate>Sat, 03 Jul 2021 04:36:54 GMT</pubDate>
            <description><![CDATA[<h3 id="📌-class형-컴포넌트-특징">📌 Class형 컴포넌트 특징</h3>
<p>참고 link : <a href="https://velog.io/@once_developer/6%EC%9E%A5.-Class%ED%98%95-Component-Project">6장. Class형 컴포넌트와 Function형 컴포넌트 (+Hook)</a></p>
<h3 id="🐱-github">🐱 Github</h3>
<p><a href="https://github.com/OnceDeveloper/Study.React/tree/master/habit-tracker">habit-tracker project</a></p>
<h3 id="📍-project-소개--habit-tracker-">📍 Project 소개 ( habit-tracker )</h3>
<blockquote>
<h4 id="습관관리-프로젝트">습관관리 프로젝트</h4>
</blockquote>
<ul>
<li>습관들(Habits)을 추가할 수도 있고 삭제할 수도 있으며
원하는 습관의 횟수를 추가, 감소 할 수 있다.<ul>
<li>결과  Page 
<img src="https://images.velog.io/images/once_developer/post/a933482d-ee48-4e9c-8989-785b10ea0455/image.png" alt="habit-tracker UI"></li>
</ul>
</li>
</ul>
<h3 id="📝-실습-code">📝 실습 Code</h3>
<blockquote>
</blockquote>
<ul>
<li><h4 id="appjsx">app.jsx</h4>
<ul>
<li>state
<code>habits</code></li>
<li>render
<code>&lt;Navbar/&gt;</code>
<code>&lt;Habits/&gt;</code>
```jsx
import React, { Component, Fragment } from &#39;react&#39;;
import &#39;./app.css&#39;;
import Habits from &#39;./components/habits&#39;;
import Navbar from &#39;./components/navbar&#39;;
//
class App extends Component {
//&#39;습관들(habits)&#39;을 state로 설정
state = {
habits: [
  { id: 1, name: &#39;Reading&#39;, count: 0 },
  { id: 2, name: &#39;Running&#39;, count: 0 },
  { id: 3, name: &#39;Coding&#39;, count: 0 }
]
}
/**
state의 count를 1씩 증가시키는 함수 (map함수 이용)
map() : 현재 state의 habits을 순차적으로 돌며 
하위 컴포넌트에서 받은 &#39;습관(habit)&#39;의 id값과 
현재 state로 설정된 &#39;습관들(habits)&#39;의 id값을 비교하여 
id 값이 같은 경우에(== &#39; + &#39; 버튼를 눌렀을 때 전달받은 habit)
state의 해당 habit의 count값을 1 더해준다.
(아래 코드의 item은 &#39;habits&#39;의 &#39;habit&#39;을 의미 / item이란 변수명은 코더의 마음대로 설정)</li>
<li>/
handleIncrement = (habit) =&gt; {
 const copyHabits = this.state.habits.map(item =&gt; {
   if (item.id === habit.id) {<pre><code> return { ...habit, count: habit.count + 1 }</code></pre>   }
   return item;
 })
 this.setState({
   habits: copyHabits
 })
}
/**
state의 count를 1씩 감소시키는 함수 (map함수 이용)
위의 handleIncrement와 동일한 개념으로 동작하고,
추가로 마이너스가 연산되었을 때 0미만으로 떨어지는 경우
state를 0으로 설정해준다.</li>
<li>/
handleDecrement = (habit) =&gt; {
 const copyHabits = this.state.habits.map(item =&gt; {
   if (item.id === habit.id) {<pre><code> const count = habit.count - 1;
 return { ...habit, count: count &lt; 0 ? 0 : count };</code></pre>   }
   return item;
 })
 this.setState({
   habits: copyHabits
 })
}
/**
habit을 삭제하는 함수 (filter함수 이용)
filter() : 현재 state의 habits을 순차적으로 돌며 
선택된 habit인 경우를 제외하고 남은 habits를 leftHabits에 담고 이를 현재 state값에 적용한다.
(== 선택된 habit만 제거한다.)
(아래 코드의 item은 &#39;habits&#39;의 &#39;habit&#39;을 의미 / item이란 변수명은 코더의 마음대로 설정)</li>
<li>/
handleDelete = (habit) =&gt; {
 const leftHabits = this.state.habits.filter(item =&gt; item.id !== habit.id);
 this.setState({
   habits: leftHabits
 })
}
/**
habit을 추가하는 함수
현재의 state값을 복사하고(Spread Operator)
추가로 param으로 받은 name을 habit의 name으로 설정하고 추가해준다.
id값은 중복을 피해주기 위해 Date.now()함수를 이용하였다.</li>
<li>/
handleAdd = (name) =&gt; {
 const habitsCopy = [...this.state.habits, <pre><code>                 { id: Date.now(), name: name, count: 0 }
                ]</code></pre> this.setState({ habits: habitsCopy });
}
/**
habits속 모든 habit의 count를 0으로 설정해주는 함수</li>
<li>/
handleReset = () =&gt; {
 const habits = this.state.habits.map((habit) =&gt; {
   if (habit.count &gt; 0) {<pre><code> return { ...habit, count: 0 };</code></pre>   }
   return habit;
 });
 this.setState({
   habits
 })
}
render() {
 return (   <Fragment>
     <Navbar totalCount={
         this.state.habits.filter(item => item.count > 0).length
        } 
     />
     <Habits
       habits={this.state.habits}
       onIncrement={this.handleIncrement}
       onDecrement={this.handleDecrement}
       onDelete={this.handleDelete}
       onAdd={this.handleAdd}
       onReset={this.handleReset}
     />
   </Fragment>
 )
}
}
//
export default App;
```</li>
</ul>
</li>
<li><h4 id="navbarjsx">navbar.jsx</h4>
<ul>
<li>props
<code>totalCount</code><pre><code class="language-jsx">import React, { PureComponent } from &#39;react&#39;;
//
class Navbar extends PureComponent {
render() {
   return (
       &lt;div className=&quot;navbar&quot;&gt;
           &lt;i className=&quot;navbar-logo fas fa-leaf&quot;&gt;&lt;/i&gt;
           &lt;span&gt;Habit Tracker&lt;/span&gt;
           &lt;span className=&quot;navbar-count&quot;&gt;{this.props.totalCount}&lt;/span&gt;
       &lt;/div&gt;
   );
}
}
//
export default Navbar;</code></pre>
</li>
</ul>
</li>
<li><h4 id="habitsjsx">habits.jsx</h4>
<ul>
<li>props
<code>habits</code>
<code>onIncrement / onDecrement / onDelete/ onAdd / onReset</code></li>
<li>render
<code>&lt;HabitAddForm/&gt;</code>
<code>&lt;Habit/&gt;</code><pre><code class="language-jsx">import React, { Component } from &#39;react&#39;;
import Habit from &#39;./habit&#39;;
import HabitAddForm from &#39;./habitAddForm&#39;;
import HabitFilter from &#39;./habitFilter&#39;;
//
class Habits extends Component {
handleIncrement = (habit) =&gt; {
    this.props.onIncrement(habit);
}
handleDecrement = (habit) =&gt; {
    this.props.onDecrement(habit);
}
handleDelete = (habit) =&gt; {
    this.props.onDelete(habit);
}
handleAdd = (name) =&gt; {
    this.props.onAdd(name);
}
handleFilter = (name) =&gt; {
    this.props.onFilter(name);
}
render() {
    return (
        &lt;&gt;
            &lt;HabitAddForm onAdd={this.handleAdd} /&gt;
            &lt;HabitFilter onFilter={this.handleFilter} /&gt;
            &lt;ul&gt;
                {
                    this.props.habits.map((habit, index) =&gt; {
                        return (
                            &lt;Habit
                                key={habit.id}
                                habit={habit}
                                onIncrement={this.handleIncrement}
                                onDecrement={this.handleDecrement}
                                onDelete={this.handleDelete}
                            /&gt;
                        )
                    })
                }
            &lt;/ul&gt;
            &lt;button className=&quot;habits-reset&quot; 
              onClick={this.props.onReset}&gt;
              Reset All
            &lt;/button&gt;
        &lt;/&gt;
    );
}
}
//
export default Habits</code></pre>
</li>
</ul>
</li>
<li><h4 id="habitaddformjsx">habitAddForm.jsx</h4>
<ul>
<li>props
<code>onAdd</code><pre><code class="language-jsx">import React, { memo } from &#39;react&#39;;
//
const HabitAddForm = memo(props =&gt; {
const formRef = React.createRef();
const inputRef = React.createRef();
const onSubmit = (e) =&gt; {
   e.preventDefault();
   const name = inputRef.current.value;
   name &amp;&amp; props.onAdd(name);
   //inputRef.current.value = &#39;&#39;;
   formRef.current.reset();
}
//
return (
   &lt;form ref={formRef} className=&quot;add-from&quot; onSubmit={onSubmit}&gt;
       &lt;input
           ref={inputRef}
           type=&quot;text&quot;
           className=&quot;add-input&quot;
           placeholder=&quot;Habit&quot; /&gt;
       &lt;button className=&quot;add-button&quot;&gt;Add&lt;/button&gt;
   &lt;/form&gt;
);
});
//
export default HabitAddForm;</code></pre>
</li>
</ul>
</li>
<li><h4 id="habitjsx">habit.jsx</h4>
<ul>
<li>props
<code>habit</code>
<code>onIncrement / onDecrement / onDelete</code><pre><code class="language-jsx">import React, { memo } from &#39;react&#39;;
//
const Habit = memo((props) =&gt; {
 //컴포넌트가 UI상 등록이 되었을 때 : 사용자에게 보여질 때
const componentDidMount = () =&gt; {
   console.log(`habit : ${props.habit.name} mounted`);
}
//컴포넌트 지우기 전에 호출
const componentWillUnmount = () =&gt; {
   console.log(`habit : ${props.habit.name} will unmount`);
}
//컴포넌트리시브받을때
const componentWillReceiveProps = () =&gt; {
   console.log(&quot;컴포 리시브 받을 때&quot;);
}
//props 값을 못 받았을 경우에 대비해 defaultProps설정
const defaultProps = {
   id: 0,
   name: &#39;defaultProps&#39;,
   count: 0
}
const handleIncrement = () =&gt; {
   props.onIncrement(props.habit);
}
const handleDecrement = () =&gt; {
   props.onDecrement(props.habit);
}
const handleDelete = () =&gt; {
   props.onDelete(props.habit);
}
const { name, count } = props.habit;
//
return (
   &lt;li className=&quot;habit&quot;&gt;
       &lt;span className=&quot;habiit-name&quot;&gt;{name}&lt;/span&gt;
       &lt;span className=&quot;habit-count&quot;&gt;{count}&lt;/span&gt;
       &lt;button className=&quot;habit-button habit-increase&quot; 
         onClick={handleIncrement} 
       &gt;
       &lt;i className=&quot;fas fa-plus-square&quot;&gt;&lt;/i&gt;
       &lt;/button&gt;
       &lt;button className=&quot;habit-button habit-decrease&quot; 
         onClick={handleDecrement} 
       &gt;
       &lt;i className=&quot;fas fa-minus-square&quot;&gt;&lt;/i&gt;
       &lt;/button&gt;
       &lt;button className=&quot;habit-button habit-delete&quot; 
         onClick={handleDelete}  
       &gt;
       &lt;i className=&quot;fas fa-trash&quot;&gt;&lt;/i&gt;
       &lt;/button&gt;
   &lt;/li&gt;
)
})
//
export default Habit;</code></pre>
</li>
</ul>
</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[6장. Class형 컴포넌트와 Function형 컴포넌트 (+Hooks)]]></title>
            <link>https://velog.io/@once_developer/6%EC%9E%A5.-Class%ED%98%95-Component-Project</link>
            <guid>https://velog.io/@once_developer/6%EC%9E%A5.-Class%ED%98%95-Component-Project</guid>
            <pubDate>Fri, 02 Jul 2021 07:56:37 GMT</pubDate>
            <description><![CDATA[<h3 id="📌-class형-컴포넌트-특징">📌 Class형 컴포넌트 특징</h3>
<blockquote>
</blockquote>
<ul>
<li><strong>Component</strong>를 <strong>상속</strong> 받아야 한다.
<code>class Test extends React.Component{//todo..}</code></li>
<li>자신의 state, props, function 등 모두 <strong>this</strong> 키워드를 사용하여 접근해야한다.
<code>this.state.name / this.props.age / this.handleIncrement</code></li>
<li>class 안 <strong>render()</strong> 함수가 포함되어야한다.<pre><code class="language-jsx">class Test extends React.Component{ 
render(){ 
 return (&lt;h1&gt;Hello, OnceDeveloper&lt;/h1&gt;)
}
}</code></pre>
</li>
<li>멤버변수나 fucntion등은 Class가 만들어질때 한 번만 할당이 되어지고 <strong>변경되는 경우 render함수만 반복적으로 호출된다.</strong></li>
<li>LifeCycle API 이용 가능하다.<ul>
<li>공식 사이트 link : <a href="https://reactjs.org/docs/state-and-lifecycle.html">LikeCycle API </a></li>
</ul>
</li>
<li>state <ul>
<li>선언 및 초기화
<code>state = {
name : &#39;OnceDeveloper&#39;
}</code></li>
<li>변경  - <strong>setState()</strong>
<code>this.setState({name : &#39;TwiceDeveloper&#39;});</code><pre><code class="language-jsx">class Test extends React.Component {
state = {
name : &#39;OnceDeveloper&#39;
}
changeState = () =&gt; {
this.setState({name : &#39;TwiceDeveloper&#39;});
}
render{
return(&lt;div&gt;hello~ {this.state.name}&lt;div&gt;);
}
}</code></pre>
<h4 id="-test-code-">[ Test code ]</h4>
<pre><code class="language-jsx">class Test extends React.Component {
state = {
name : &#39;OnceDeveloper&#39;
}
render() {
return (
  &lt;div&gt;
    &lt;h1&gt;Hello, {this.state.name}&lt;/h1&gt;
    &lt;h1&gt;I am {this.props.age} years old&lt;/h1&gt;
  &lt;/div&gt;
);
}
}</code></pre>
</li>
</ul>
</li>
</ul>
<h3 id="📌-function형-컴포넌트-특징">📌 Function형 컴포넌트 특징</h3>
<blockquote>
</blockquote>
<ul>
<li>클래스형 컴포넌트보다 선언하기 수월하다.</li>
<li>클래스형 컴포넌트보다 메모리 자원을 덜 사용한다.</li>
<li><strong>this</strong> 키워드를 사용하지 않아도 접근 가능하다.</li>
<li><strong>props</strong>는 파라미터로 받아 사용 가능하다.</li>
<li><strong>render()</strong> 함수를 포함하지 않아도 된다.</li>
<li>state, 라이프사이클 API를 사용할 수 없다.</li>
<li>단순히 화면에 값을 출력해주고싶을 때 사용한다.<h4 id="-test-code--1">[ Test code ]</h4>
</li>
<li>Function
<code>funtion test(props){}</code><pre><code class="language-jsx">function test(props) {
return &lt;h1&gt;Hello, {props.name}&lt;/h1&gt;;
}</code></pre>
</li>
<li>Arrow Function
<code>funtion test = () =&gt; {}</code><pre><code class="language-jsx">function test = (props) =&gt;{
return &lt;h1&gt; Hello, {props.name}&lt;/h1&gt;;
}</code></pre>
</li>
</ul>
<h3 id="📌-react-hooks">📌 React Hooks</h3>
<blockquote>
</blockquote>
<ul>
<li>공식 사이트 link =&gt; <a href="https://ko.reactjs.org/docs/hooks-intro.html">React Hooks</a></li>
<li>Class 형태였던 Component를 <strong>Function을 통해 만들 수 있게 해주는 API</strong></li>
<li>Function형 컴포넌트의 장점을 갖고  Class형 컴포넌트와같은 기능들을 Hooks를 이용하여 사용할 수 있게됨.</li>
<li>Class형 컴포넌트와 달리 Function형 컴포넌트는 props나 state가 변경이 되면 코드블락 안 전체 코드가 반복되어짐 =&gt; Hooks를 이용해 이전의 값들을 저장할 수 있음.</li>
<li>state <ul>
<li>선언 및 초기화 </li>
<li><em>const  [&#39;state로 설정할 이름&#39;, &#39;state를 변경할 이름&#39;] = useState(&#39;설정할 state 초기값&#39;)*</em>
<code>const [age, setAge] = useState(20);</code></li>
<li>변경</li>
<li><em>state 선언 시 2번째 인자로 설정한 이름으로 호출 (위의 예시로 setAge)*</em>
<code>setAge(21);</code></li>
</ul>
</li>
<li><h4 id="useeffect">useEffect</h4>
<ul>
<li>처음에 로딩될 때 호출 &amp;&amp; 인자값이 업데이트 될 때 호출</li>
<li><em>componentDidMount*</em> 와 <strong>componentDidUpdate</strong>를 합친 느낌
두번째 인자를 빈 값으로[] 호출을하면 처음에만 호출하고 두번째 인자에 값을 넣으면 그 값이 변경될때마다 호출됨</li>
<li>useEffect()
<code>mount될 때 + update될 때 rendering</code></li>
<li>useEffect(,[])
<code>mount될 때만</code></li>
<li>useEffect(,[age])
<code>mount될 때 + age가 update되는 경우에만 rendering</code><h4 id="-test-code--2">[ Test code ]</h4>
<pre><code class="language-jsx">function Test = (props) =&gt; {
const [age, setAge] = useState(20);
const changeState = () =&gt; {
setAge(21);
}
//useEffect(changeState());
//useEffect(changeState(),[]);
useEffect(changeState(),[age]);
return (
 &lt;div&gt;
   I&#39;m {age} years old.
   my name is {props.name}.
  &lt;button onClick={() =&gt; changeState()}&gt;
    버튼 클릭
  &lt;/button&gt;
&lt;/div&gt;
);
}</code></pre>
</li>
</ul>
</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[5장. React State 사용]]></title>
            <link>https://velog.io/@once_developer/5%EC%9E%A5.-React-State-%EC%82%AC%EC%9A%A9</link>
            <guid>https://velog.io/@once_developer/5%EC%9E%A5.-React-State-%EC%82%AC%EC%9A%A9</guid>
            <pubDate>Mon, 14 Jun 2021 07:45:24 GMT</pubDate>
            <description><![CDATA[<h3 id="📌-state란">📌 State란?</h3>
<blockquote>
</blockquote>
<ul>
<li>State는 각 컴포넌트가 가지고 있는 개별적인 상태값이다.</li>
<li>클래스형 컴포넌트를 작성할때는 해당 클래스 내부 맨 위쪽에 작성하는 것이 일반적이며 State는 객체이다.</li>
<li>State는 &#39;문자&#39;나 &#39;숫자&#39;가 아닌 <strong>객체형태</strong>로 생성</li>
<li>값을 변경할 때는 언제나 <strong>setState</strong>라는 함수를 사용</li>
<li>State에 데이터 저장하는 이유 : <strong>State가 변경되면 HTML이 자동으로 재렌더링 됨</strong>
(HTML이 새로고침 없이도 스무스하게 변경됨)</li>
</ul>
<h3 id="📍-props와-state">📍 Props와 State</h3>
<blockquote>
</blockquote>
<ul>
<li><h4 id="공통점">공통점</h4>
<ul>
<li>State는 Props처럼 App 컴포넌트의 렌더링 결과물에 영향을 주는 데이터를 갖고 있는 객체</li>
</ul>
</li>
<li><h4 id="차이점">차이점</h4>
<ul>
<li><strong>State</strong> : <strong>함수 내에 선언된 변수처럼</strong> 컴포넌트 안에서 관리됨(변경 가능)</li>
<li><strong>Props</strong> : <strong>함수 매개변수처럼</strong> 컴포넌트에 전달되는 <strong>읽기전용</strong></li>
</ul>
</li>
<li>Props를 사용했는데도 State를 사용하는 이유는, 사용하는 쪽과 구현하는 쪽을 철저하게 분리시켜서 양쪽의 편의성을 각자 도모하는 것에 있음</li>
</ul>
<h3 id="📝-실습-code">📝 실습 Code</h3>
<blockquote>
</blockquote>
<ul>
<li><h4 id="appjs">App.js</h4>
<pre><code class="language-jsx">import React, { Component, Fragment } from &#39;react&#39;;
import Counter from &#39;./Counter&#39;;
//
class App extends Component {
render() {
  return &lt;Counter/&gt;;
}
}
//
export default App;</code></pre>
</li>
<li><h4 id="counterjs">Counter.js</h4>
<pre><code class="language-jsx">import React, { Component } from &#39;react&#39;;
//
class Counter extends Component {
//state는 문자 나 숫자가 아닌 &#39;객체&#39;로
state = {
  number: 0
};
handleIncrease = () =&gt; {
  console.log(this.state);
  this.setState({
    number: this.state.number + 1
  });
};
handleDecrease = () =&gt; {
  this.setState({
    number: this.state.number - 1
  });
};
render() {
  return (
    &lt;div&gt;
      &lt;h1&gt;카운터&lt;/h1&gt;
      &lt;div&gt;값 : {this.state.number}&lt;/div&gt;
      &lt;button onClick={this.handleIncrease}&gt;+&lt;/button&gt;
      &lt;button onClick={this.handleDecrease}&gt;-&lt;/button&gt;
    &lt;/div&gt;
  );
}
//
}
export default Counter;</code></pre>
</li>
<li><h4 id="일반-함수-사용식으로-쓰는-경우">일반 함수 사용식으로 쓰는 경우</h4>
<code>this를 인식하지 못 하여 추가 작업이 필요.</code><pre><code class="language-js">&lt;&lt; 예시 &gt;&gt;
constructor(props){
super(props);
this.handleIncrease = this.handleIncrease.bind(this);
this.handleDecrease = this.handleDecrease.bind(this);
}</code></pre>
</li>
<li><h4 id="결과--page">결과  Page</h4>
<img src="https://images.velog.io/images/once_developer/post/c5be4854-1f1c-45d8-9a45-efafa57bc1f2/image.png" alt=""></li>
</ul>
<p>유튜버 출처 : <a href="https://www.youtube.com/watch?v=mYEZh6TV10M&amp;list=PL9FpF_z-xR_E4rxYMMZx5cOpwaiwCzWUH&amp;index=9">Minjun Kim</a></p>
]]></description>
        </item>
        <item>
            <title><![CDATA[4장. React Props 사용]]></title>
            <link>https://velog.io/@once_developer/4%EC%9E%A5.-React-Props-%EC%82%AC%EC%9A%A9</link>
            <guid>https://velog.io/@once_developer/4%EC%9E%A5.-React-Props-%EC%82%AC%EC%9A%A9</guid>
            <pubDate>Mon, 14 Jun 2021 06:14:47 GMT</pubDate>
            <description><![CDATA[<h3 id="📌-props란">📌 Props란?</h3>
<blockquote>
</blockquote>
<ul>
<li>컴포넌트 끼리 값을 전달하는 수단</li>
<li>상위 컴포넌트에서 하위 컴포넌트로 데이터를 전달할 때 사용한다.
(하위 컴포넌트가 상위 컴포넌트의 값을 바로 참조할 수 없다는 의미를 뜻함)</li>
<li>객체, 배열 등 유형과 상관없이 모든 것이 전달 가능</li>
</ul>
<h3 id="💡-defaultprops">💡 defaultProps</h3>
<blockquote>
</blockquote>
<ul>
<li>실수로 Props 를 빼먹은 경우, 특정 상황에 Props 를 일부러 비워야 할 경우를 대비해 설정</li>
<li><h4 id="설정-방법-1-최신-방식">설정 방법-1 (최신 방식)</h4>
<code>render() 윗 부분에 작성</code><pre><code class="language-jsx">static defaultProps = {
name: &#39;기본이름&#39;
};</code></pre>
</li>
<li><h4 id="설정-방법-2">설정 방법-2</h4>
<code>class 밑(밖)에서 설정</code><pre><code class="language-jsx">class명.defaultProps = {
name: &#39;OnceDeveloper&#39;
};</code></pre>
</li>
</ul>
<h3 id="📝-실습-코드">📝 실습 코드</h3>
<blockquote>
</blockquote>
<ul>
<li><h4 id="appjs">App.js</h4>
<pre><code class="language-jsx">import React, { Component, Fragment } from &#39;react&#39;;
import MyName from &#39;./MyName&#39;;
//
class App extends Component {
render() {
  return &lt;MyName name=&quot;리액트&quot; /&gt;;
}
}
//
export default App;</code></pre>
</li>
<li><h4 id="class형-컴포넌트-이용한-mynamejs">Class형 컴포넌트 이용한 MyName.js</h4>
<pre><code class="language-jsx">import React, { Component } from &#39;react&#39;;
//
class MyName extends Component {
//defaultProps 첫번째 방법 (최신 방식)
static defaultProps = {
  name: &#39;기본이름&#39;
};
render() {
  return (
    &lt;div&gt;
      안녕하세요! 제 이름은 &lt;b&gt;{this.props.name}&lt;/b&gt;입니다.
    &lt;/div&gt;
  );
}
}
//defaultProps 두번째 방법
MyName.defaultProps = {
name: &#39;OnceDeveloper&#39;
};
//
export default MyName;</code></pre>
</li>
<li><h4 id="함수형-컴포넌트-이용한-mynamejs">함수형 컴포넌트 이용한 MyName.js</h4>
<code>기능 없이 받아서 보여주기만 하는 경우 주로 이용</code>
<code>코드의 상단에 { Component } 를 import하지 않아도 됨.</code><pre><code class="language-jsx">import React from &#39;react&#39;;
//
const MyName = ({name}) =&gt; {
return (
  &lt;div&gt;
    안녕하세요 ! 제 이름은 {name} 입니다.
  &lt;/div&gt;
)
};
//
MyName.defaultProps = {
name : &#39;OnceDeveloper&#39;
}
//
export default MyName;</code></pre>
</li>
<li><h4 id="결과--page-1--appjs에서-props를-호출">결과  Page 1 : App.js에서 props를 호출</h4>
<img src="https://images.velog.io/images/once_developer/post/247b4c02-4bcd-4655-8a79-3d5c245505eb/image.png" alt=""></li>
<li><h4 id="결과--page-2--defaultprops-적용">결과  Page 2 : defaultProps 적용</h4>
<img src="https://images.velog.io/images/once_developer/post/7624edac-8511-4210-babe-e28022c42345/image.png" alt=""></li>
</ul>
<p>유튜버 출처 : <a href="https://www.youtube.com/watch?v=tZLQ-cNCf70&amp;list=PL9FpF_z-xR_E4rxYMMZx5cOpwaiwCzWUH&amp;index=8">Minjun Kim</a></p>
]]></description>
        </item>
        <item>
            <title><![CDATA[3장. React 삼항연산자와 주석처리]]></title>
            <link>https://velog.io/@once_developer/3%EC%9E%A5.-React-%ED%95%A8%EC%88%98-%EC%A6%89%EC%8B%9C-%EC%82%AC%EC%9A%A9%EA%B3%BC-%EC%82%BC%ED%95%AD%EC%97%B0%EC%82%B0%EC%9E%90</link>
            <guid>https://velog.io/@once_developer/3%EC%9E%A5.-React-%ED%95%A8%EC%88%98-%EC%A6%89%EC%8B%9C-%EC%82%AC%EC%9A%A9%EA%B3%BC-%EC%82%BC%ED%95%AD%EC%97%B0%EC%82%B0%EC%9E%90</guid>
            <pubDate>Mon, 14 Jun 2021 06:04:19 GMT</pubDate>
            <description><![CDATA[<h3 id="📍-함수">📍 함수</h3>
<blockquote>
</blockquote>
<ul>
<li><h4 id="삼항-연산자">삼항 연산자</h4>
<code>{name === &#39;velopert!&#39; &amp;&amp; &lt;div&gt;벨로퍼트다!&lt;/div&gt;}</code></li>
<li>JSX 함수 즉시 호출<pre><code class="language-jsx">import React, { Component, Fragment } from &#39;react&#39;;
import &#39;./App.css&#39;;
class App extends Component {
render() {
  const name = &#39;velopert!&#39;;
  const value = 1;
 //
  return (
    &lt;div&gt;
        {
          (()=&gt; {
            if (value === 1) return &lt;div&gt;1이다!&lt;/div&gt;
            if (value === 2) return &lt;div&gt;2이다!&lt;/div&gt;
            if (value === 3) return &lt;div&gt;3이다!&lt;/div&gt;
            return &lt;div&gt; 없다! &lt;/div&gt;
          })()
        }
    &lt;/div&gt;
  );
}
}
export default App;</code></pre>
</li>
</ul>
<h3 id="💡-jsx-주석-처리">💡 JSX 주석 처리</h3>
<blockquote>
</blockquote>
<ul>
<li><h4 id="방법-1--tag-속-입력">방법 1 : Tag 속 입력</h4>
<pre><code class="language-jsx">&lt;h1 //주석 입력
&gt;&gt;리액트
&lt;/h1&gt;</code></pre>
</li>
<li><h4 id="방법-2----">방법 2 : { /**/ }</h4>
<pre><code class="language-jsx">{ /* 주석 입력 / }</code></pre>
</li>
</ul>
<p>유튜버 출처 : <a href="https://www.youtube.com/watch?v=N96EJm09Pxo&amp;list=PL9FpF_z-xR_E4rxYMMZx5cOpwaiwCzWUH&amp;index=7">Minjun Kim</a></p>
]]></description>
        </item>
        <item>
            <title><![CDATA[2장. React에선 HTML대신 JSX]]></title>
            <link>https://velog.io/@once_developer/%EB%A6%AC%EC%95%A1%ED%8A%B8%EC%97%90%EC%84%A0-HTML%EB%8C%80%EC%8B%A0-JSX</link>
            <guid>https://velog.io/@once_developer/%EB%A6%AC%EC%95%A1%ED%8A%B8%EC%97%90%EC%84%A0-HTML%EB%8C%80%EC%8B%A0-JSX</guid>
            <pubDate>Wed, 09 Jun 2021 08:16:36 GMT</pubDate>
            <description><![CDATA[<h3 id="2장-react에선-html대신-jsx">2장. React에선 HTML대신 JSX</h3>
<hr>
<h4 id="📌-jsx란-javascript-extension">📌 JSX란? (JavaScript eXtension)</h4>
<blockquote>
<p>쉽게 말해 <strong>HTML 문법을 JavaScript 코드 내부에 쓴 것</strong>. 
어렵게 말해 JavaScript eXtension.. JavaScript의 확장 버전이고 결론은 자바스크립트이다.
즉, JSX는 자바스크립트 안에서 HTML 문법을 사용해서 view를 구성할 수 있게 도와주는 자바스크립트 문법으로, 리액트 개발에 엄청난 도움을 주고 있다.</p>
</blockquote>
<h4 id="📝-실습-code">📝 실습 Code</h4>
<blockquote>
</blockquote>
<ul>
<li><h4 id="appjs">App.js</h4>
<pre><code class="language-jsx">import logo from &#39;./logo.svg&#39;;
import &#39;./App.css&#39;;
import reactDom from &#39;react-dom&#39;;
import { getQueriesForElement } from &#39;@testing-library/dom&#39;;
//
function App() {
let posts = &#39;강남 고기 맛집&#39;;
let styleObj = {color:&#39;red&#39;, fontSize:&#39;30px&#39;};
//fontSize : 15 + 15 + &#39;px&#39;도 가능
function 함수(){
  return 100
}
return (
  &lt;div className=&quot;App&quot;&gt;
    &lt;div className=&quot;black-nav&quot;&gt;
      &lt;div className={posts} style={ {color : &#39;blue&#39;, fontSize : &#39;30px&#39;} }&gt;
         개발 Blog
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;img src={logo}&gt;&lt;/img&gt;
    &lt;h4&gt;{posts}&lt;/h4&gt;
    &lt;h4&gt;{함수()}&lt;/h4&gt;
    &lt;div style={styleObj}&gt; 스타일 오브젝트 실험 &lt;/div&gt;
  &lt;/div&gt;
);
}
//
export default App;</code></pre>
</li>
<li><h4 id="appcss">App.css</h4>
<pre><code class="language-css">body{
font-family:
&#39;nanumsquare&#39;;
}
.black-nav{
background : black;
width : 100%;
display : flex;
color : white;
padding : 20px;
font-weight : 600;
font-size : 20px;
}</code></pre>
</li>
</ul>
<h4 id="💡-중요-문법">💡 중요 문법</h4>
<blockquote>
</blockquote>
<ul>
<li><h4 id="class-부여">class 부여</h4>
<ul>
<li><strong>class</strong>가 아닌 <strong>className</strong>을 입력
<strong>why?</strong> javascript는 class라는 명령어가 있기 때문에 className으로 
<code>ex) &lt;div className=&quot;클래스명&quot;&gt;</code></li>
</ul>
</li>
<li><h4 id="style-부여">style 부여</h4>
<ul>
<li>무조건 Object형식으로 집어넣어야 함</li>
<li><em>why?*</em> javascript에서 쓸 수 있는 민감한 기호들이 많기 때문
<code>ex) &lt;div style={ {color : &#39;blue&#39;, fontSize : &#39;30px&#39;} }&gt;</code></li>
<li>무조건 중괄호(&#39;{}&#39;)를 이용</li>
<li>속성명은 camelCase 관습으로 작성
<code>font-size (x) fontSize(O)</code></li>
</ul>
</li>
</ul>
<h4 id="❓-react를-사용하는-이유">❓ React를 사용하는 이유</h4>
<blockquote>
</blockquote>
<ul>
<li><h4 id="데이터-바인딩을-쉽게-해줌-서버에서-가져온-데이터들을-html에-꽂아넣는-것">데이터 바인딩을 쉽게 해줌 (서버에서 가져온 데이터들을 HTML에 꽂아넣는 것)</h4>
<code>기존의 javascript의 경우 document.getElementById().innerHTML = &#39;&#39;</code>
<code>JSX의 경우 중괄호(&#39;{}&#39;)를 이용</code></li>
</ul>
<ol>
<li>변수를 이용하여 출력하는 방법<pre><code class="language-JSX">let posts = &#39;강남 고기 맛집&#39;
&lt;h4&gt; { posts } &lt;/h4&gt;</code></pre>
</li>
<li>함수를 이용하여 출력하는 방법<pre><code class="language-JSX">function 함수() {
return 100;
}
&lt;h4&gt; { 함수() } &lt;/h4&gt;</code></pre>
</li>
<li>import를 이용하여 이미지를 출력하는 방법<pre><code class="language-JSX">import logo from &#39;./logo.svg&#39;;
&lt;img src= { logo }/&gt;</code></pre>
</li>
<li>변수를 이용하여 style 부여<pre><code class="language-JSX">let posts = {color : &#39;blue&#39;, fontSize : &#39;30px&#39;};
&lt;div style= { posts }&gt;</code></pre>
</li>
</ol>
<h3 id="오늘의-결과물">&lt;오늘의 결과물&gt;</h3>
<p><img src="https://images.velog.io/images/once_developer/post/e5bf9d03-71bb-4ed8-a890-3c9e973f7423/image.png" alt="React결과물">
참고 유튜버 : <a href="https://www.youtube.com/watch?v=FqnAFX9lQPQ">코딩애플</a></p>
]]></description>
        </item>
        <item>
            <title><![CDATA[1장. React 설치와 셋팅 방법]]></title>
            <link>https://velog.io/@once_developer/Study.React</link>
            <guid>https://velog.io/@once_developer/Study.React</guid>
            <pubDate>Tue, 08 Jun 2021 17:25:36 GMT</pubDate>
            <description><![CDATA[<h3 id="1장-react-설치와-셋팅-방법">1장. React 설치와 셋팅 방법</h3>
<hr>
<h4 id="📌-react란">📌 React란?</h4>
<blockquote>
</blockquote>
<ul>
<li>리액트는 페이스북이 만든 사용자 UI 구축을 위한 라이브러리이다. </li>
<li>하나의 단일 url을 가지고 SPA(Single Page Application)으로 사이트를 표현하는 것을 가능케하는 프레임워크다.</li>
<li>대표적인 특징<ul>
<li>JSX 문법</li>
<li>Component 기반</li>
<li>Virtual DOM </li>
<li>Data Flow</li>
<li>Props and State</li>
</ul>
</li>
</ul>
<h4 id="1-필요-툴-설치">1. 필요 툴 설치</h4>
<blockquote>
</blockquote>
<ul>
<li><h4 id="window">Window</h4>
<table>
<thead>
<tr>
<th align="center">Tool</th>
<th align="center">version</th>
<th align="center">remark</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><a href="https://nodejs.org/ko/download/">node.js</a></td>
<td align="center">최신 버전</td>
<td align="center">npm 기능 이용</td>
</tr>
<tr>
<td align="center"><a href="https://classic.yarnpkg.com/en/docs/install#windows-stable">yarn</a></td>
<td align="center">최신 버전</td>
<td align="center">npm 다운로드 후 cmd에 입력 <strong>(npm install --global yarn)</strong></td>
</tr>
<tr>
<td align="center"><a href="https://code.visualstudio.com/download">visual studio code</a></td>
<td align="center">최신 버전</td>
<td align="center">terminal 기능 필요</td>
</tr>
</tbody></table>
</li>
<li><h4 id="mac">Mac</h4>
<table>
<thead>
<tr>
<th align="center">Tool</th>
<th align="center">version</th>
<th align="center">remark</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><a href="https://brew.sh/index_ko">homebrew</a></td>
<td align="center">최신 버전</td>
<td align="center">yarn 기능 이용 <strong>(brew install  yarn)</strong></td>
</tr>
<tr>
<td align="center"><a href="https://code.visualstudio.com/download">visual studio code</a></td>
<td align="center">최신 버전</td>
<td align="center">terminal 기능 필요</td>
</tr>
</tbody></table>
</li>
<li><h4 id="vscode-extensions-필수-x--출처">VSCode Extensions (필수 X) =&gt; <a href="https://www.youtube.com/watch?v=bS9yTI2fC0w">출처</a></h4>
<table>
<thead>
<tr>
<th align="center">Tool</th>
<th align="center">remark</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><strong>Prettier</strong></td>
<td align="center">자동 코드 정렬 <strong>(셋팅 방법 : File --&gt; Preference --&gt; Setting --&gt; editor.format 입력 [ Setting 입력 창 ] --&gt; Format On Save 체크)</strong></td>
</tr>
<tr>
<td align="center"><strong>Eslint</strong></td>
<td align="center">Javascript의 스타일 가이드를 따르지 않거나 문제가 있는 안티 패턴들을 찾아서 일관된 코드 스타일로 재정렬 해주도록 도움</td>
</tr>
<tr>
<td align="center">ES7 React/Redux/GraphQL/React-Native snippets</td>
<td align="center">react 구조 생성 지원 <strong>(예약어 :: rcc =&gt; react class component, rsi =&gt; react function component)</strong></td>
</tr>
<tr>
<td align="center">Highlight Matching Tag</td>
<td align="center">태그를 클릭시 닫는 태그 함께 highlight, 가독성 좋음</td>
</tr>
<tr>
<td align="center">Material Theme</td>
<td align="center">테마 정하기</td>
</tr>
<tr>
<td align="center">Bracket Pari Colorizer</td>
<td align="center">괄호마다 색깔을 다르게 줌</td>
</tr>
<tr>
<td align="center">Indent-rainbow</td>
<td align="center">들여쓰기 된 부분을 하이라이트로 표시</td>
</tr>
<tr>
<td align="center">Auto Rename Tag</td>
<td align="center">앞 Tag 변경 시 뒤 Tag 자동 변경</td>
</tr>
<tr>
<td align="center">CSS Peek</td>
<td align="center">HTML에서 ctrl 누른 채 클릭 시 정의된 css로 이동</td>
</tr>
<tr>
<td align="center">HTML CSS Support</td>
<td align="center">HTML에서 CSS 자동완성 이용하게 해줌</td>
</tr>
<tr>
<td align="center">Live Server</td>
<td align="center">CSS 수정 시 브라우저 창 새로고침 안 해도 됨 <strong>(Command Palette&gt; Live Server : Open with Live Server 실행)</strong></td>
</tr>
<tr>
<td align="center">#### 💡 Prettier 세팅 방법 =&gt; <a href="https://leehwarang.github.io/docs/tech/2020-06-24-prettier.html">출처</a></td>
<td align="center"></td>
</tr>
</tbody></table>
</li>
<li>settings.json 수정<pre><code>{
&quot;editor.formatOnSave&quot;: true,
//여기부터 추가함
&quot;javascript.format.enable&quot;: false,
&quot;editor.defaultFormatter&quot;: &quot;esbenp.prettier-vscode&quot;,
&quot;prettier.arrowParens&quot;: &quot;avoid&quot;,
&quot;prettier.tabWidth&quot;: 2,
&quot;prettier.semi&quot;: false,
&quot;prettier.singleQuote&quot;: true,
&quot;prettier.printWidth&quot;: 80,
&quot;prettier.trailingComma&quot;: &quot;es5&quot;
}</code></pre><h4 id="💡-yarn-오류-시-해결-방법--출처">💡 yarn 오류 시 해결 방법 =&gt; <a href="https://dang2dangdang2.tistory.com/173">출처</a></h4>
</li>
<li>powershell 에서 권한 설정<ul>
<li>PowerShell 을 <strong>관리자 권한</strong>으로 실행</li>
<li><strong>get-help Set-ExecutionPolicy</strong>  명령어 입력 후 Y(예) 입력</li>
<li><strong>Set-ExecutionPolicy RemoteSigned</strong> 명령어 입력 후 Y(예) 입력</li>
</ul>
</li>
</ul>
<h4 id="2-react-설치-및-프로젝트-생성-visual-studio-code툴로-진행">2. React 설치 및 프로젝트 생성 [visual studio code툴로 진행]</h4>
<blockquote>
</blockquote>
<ul>
<li>프로젝트를 생성할 React 폴더 생성
<code>ex) C:\Users\문서\React class</code></li>
<li>visual studio code에서 생성한 Folder Open 
<code>단축키 : ctrl+K, ctrl+O</code></li>
<li>visual studio code의 terminal에서 React 설치 명령어 입력
<code>npx 명령어 : npx create-react-app blog</code>
<code>yarn 명령어 : yarn create react-app blog</code>
```</li>
<li>npx : lib 설치를 도와주는 명령어[node.js 설치 시 이용 가능]</li>
<li>create-react-app : react 셋팅이 다 된 boilerplate, 한번에 설치할 수 있도록 도와주는 library</li>
<li>blog : blog라는 이름의 react 프로젝트를 생성하겠다.
```</li>
<li>설치 완료 후 visual studio code에서 생성된 프로젝트 Folder Open
<code>위의 예시로는 blog 폴더를 Open 합니다.</code></li>
</ul>
<h4 id="3-react-프로젝트-구조">3. React 프로젝트 구조</h4>
<blockquote>
</blockquote>
<ul>
<li>/src/app.js : 메인 페이지에 들어갈 HTML을 작성하는 곳 (index.html 유사)
``` react</li>
<li>app.js 코드 중 p태그에 해당되는 부분을 수정해보면 바뀐 부분을 쉽게 확인할 수 있다.<p>
 Edit <code>src/App.js</code> and save to reload.
</p>
```</li>
<li>public/index.html : 메인페이지</li>
<li>src/index.js : app.js에 있는 것을 index.html에 넣도록 명령하는 곳
<code>code : document.getElementById(&#39;root&#39;)</code></li>
<li>node_modules : 라이브러리 모은 폴더</li>
<li>package.json : 설치한 라이브러리 목록</li>
<li>public : static 파일 보관함
<code>ex) image, fivicon ...</code></li>
</ul>
<h4 id="4-실시간-미리보기">4. 실시간 미리보기</h4>
<blockquote>
</blockquote>
<ul>
<li>명령어 : npm start || yarn start
<code>브라우저 자동으로 안 열리는 경우 표시된 주소값 입력</code>
<img src="https://images.velog.io/images/once_developer/post/9a5fe000-cbd3-4a21-9daa-437152965781/%ED%99%94%EB%A9%B4%20%EC%BA%A1%EC%B2%98%202021-06-09%20015735.png" alt="주소값"></li>
</ul>
<h4 id="오늘의-결과물">&lt;오늘의 결과물&gt;</h4>
<p><img src="https://images.velog.io/images/once_developer/post/74509b57-981f-4256-9369-d0139edaee92/image.png" alt="오늘의 결과물"></p>
<p>참고 유튜버 : <a href="https://www.youtube.com/channel/UCSLrpBAzr-ROVGHQ5EmxnUg">코딩애플</a></p>
]]></description>
        </item>
    </channel>
</rss>