Skip to content

Commit 4e2acf5

Browse files
committed
add what-is-controlled-component.md
1 parent 93b72d4 commit 4e2acf5

File tree

4 files changed

+44
-1
lines changed

4 files changed

+44
-1
lines changed

_data/navigation.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ docs:
9898
url: /state-vs-props
9999
- title: "Creating Stateless Function Components"
100100
url: /create-stateless-function-component
101+
- title: React Forms Controlled Component
102+
children:
103+
- title: "What is Controlled Component?"
104+
url: /what-is-controlled-component
101105
# - title: "Installation"
102106
# url: /install-create-react-app
103107
# - title: "Structure"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
title: "What is Controlled Component?"
3+
permalink: /what-is-controlled-component
4+
excerpt: "What is Controlled Component? - Learn React"
5+
last_modified_at: 2018-05-21T15:58:49-04:00
6+
---
7+
8+
A Controlled Component is one that takes its current value through state and notifies changes through callbacks like `onChange`.
9+
10+
For example below, I log the name when it is submitted, with controlled component:
11+
12+
<p data-height="265" data-theme-id="0" data-slug-hash="pVBwwa" data-default-tab="js,result" data-user="Bunlong" data-embed-version="2" data-pen-title="pVBwwa" class="codepen">See the Pen <a href="https://codepen.io/Bunlong/pen/pVBwwa/">pVBwwa</a> by Bunlong (<a href="https://codepen.io/Bunlong">@Bunlong</a>) on <a href="https://codepen.io">CodePen</a>.</p>
13+
<script async src="https://static.codepen.io/assets/embed/ei.js"></script>
14+
15+
`<input>` form element takes its current value through `this.state.value`. `handleChange` runs on every keystroke to update `this.state.value`, the displayed value will update as the user types.

_site/index.html

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232

3333

34-
<meta property="article:published_time" content="2018-05-22T14:00:12+07:00">
34+
<meta property="article:published_time" content="2018-05-23T14:20:48+07:00">
3535

3636

3737

@@ -592,6 +592,26 @@
592592

593593
</li>
594594

595+
<li>
596+
597+
<span class="nav__sub-title">React Forms Controlled Component</span>
598+
599+
600+
601+
<ul>
602+
603+
604+
605+
606+
607+
608+
609+
<li><a href="/what-is-controlled-component" class="">What is Controlled Component?</a></li>
610+
611+
</ul>
612+
613+
</li>
614+
595615
</ul>
596616
</nav>
597617

_site/sitemap.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,10 @@
165165
<lastmod>2018-05-22T02:58:49+07:00</lastmod>
166166
</url>
167167
<url>
168+
<loc>/what-is-controlled-component</loc>
169+
<lastmod>2018-05-22T02:58:49+07:00</lastmod>
170+
</url>
171+
<url>
168172
<loc>/</loc>
169173
</url>
170174
</urlset>

0 commit comments

Comments
 (0)