Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
form validation in react
Search
yiminghe
March 19, 2015
Technology
4
560
form validation in react
do form validation using react
yiminghe
March 19, 2015
Tweet
Share
More Decks by yiminghe
See All by yiminghe
小程序终端技术架构
yiminghe
0
230
支付宝小程序的开放架构
yiminghe
0
190
gitc2016 react based architecture
yiminghe
1
150
antd at qcon2016
yiminghe
1
220
react-based architecture
yiminghe
2
160
React Ecosystem At Ant Financial
yiminghe
4
2.2k
ant design preview
yiminghe
1
290
react best practice
yiminghe
3
210
react at alipay
yiminghe
43
4.4k
Other Decks in Technology
See All in Technology
AI Agentと MCP Serverで実現する iOSアプリの 自動テスト作成の効率化
spiderplus_cb
0
470
リーダーになったら未来を語れるようになろう/Speak the Future
sanogemaru
0
270
GC25 Recap+: Advancing Go Garbage Collection with Green Tea
logica0419
1
370
pprof vs runtime/trace (FlightRecorder)
task4233
0
150
C# 14 / .NET 10 の新機能 (RC 1 時点)
nenonaninu
1
1.5k
Trust as Infrastructure
bcantrill
0
310
ZOZOのAI活用実践〜社内基盤からサービス応用まで〜
zozotech
PRO
0
160
OCI Network Firewall 概要
oracle4engineer
PRO
1
7.8k
ユニットテストに対する考え方の変遷 / Everyone should watch his live coding
mdstoy
0
120
GopherCon Tour 概略
logica0419
2
170
FastAPIの魔法をgRPC/Connect RPCへ
monotaro
PRO
1
710
GA technologiesでのAI-Readyの取り組み@DataOps Night
yuto16
0
260
Featured
See All Featured
The Art of Programming - Codeland 2020
erikaheidi
56
14k
How STYLIGHT went responsive
nonsquared
100
5.8k
KATA
mclloyd
32
15k
Fireside Chat
paigeccino
40
3.7k
Testing 201, or: Great Expectations
jmmastey
45
7.7k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Building Better People: How to give real-time feedback that sticks.
wjessup
368
20k
Gamification - CAS2011
davidbonilla
81
5.5k
Rails Girls Zürich Keynote
gr2m
95
14k
jQuery: Nuts, Bolts and Bling
dougneiner
64
7.9k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
114
20k
Building Applications with DynamoDB
mza
96
6.6k
Transcript
Form Valida+on In React
[email protected]
form • Tradi+onal way • Library way
• React way – rc-‐form-‐valida+on
Tradi+onal way
Problems • Maintenance – Script and html is separated
– A lot of duplica+on – Hard to reuse code – …
Library way • hFp://jqueryvalida+on.org/documenta+on/
Library way • But you s+ll need to get data
when submit! • hFps://api.jquery.com/serialize/
Problems Customiza/on! Invasion!
In Short
DOM Driven
React Way DATA
Driven
Introduce • rc-‐form-‐valida+on • hFps://github.com/react-‐component/form-‐ valida+on
in general
Step by step -‐1 • Valida+on.FieldMixin – handleValidate – setField
Step by step -‐2 • Declare data model – formData:
field value geFer and seFer – Status: field status (errors,valida+ng…)
Step by step -‐3 • Just render html by data
model and valida+on rules – handleValidate provided by mixins – Declare rules in Validator – Wrap input by Validator and Valida+on
Step by step -‐4 • Validate on submit and get
data – Call validate method – Just get data from data model (two-‐way binding)
Advanced usage • Asynchronous valida+on • Validate custom
component
Asynchronous valida+on • Use validator func+on
Validate custom component • Validate custom component which supports
onChange props, such as rc-‐calendar:
What’s next • Isomorphic Valida+on – hFps://github.com/yiminghe/async-‐validator • rc-‐form-‐valida/on
depends on async-‐validator • async-‐validator can be run at nodejs! Let’s share some valida/on rules!
Try hFp://react-‐component.github.io/form-‐ valida+on/build/examples/form.html