September 2018
Next Generation Forms with
React Final Form
Erik Rasmussen
Slide 2
Slide 2 text
Thanks to our sponsors!
Slide 3
Slide 3 text
Forms
Slide 4
Slide 4 text
Forms are Hard
Slide 5
Slide 5 text
Form UI is diļ¬erent
⢠Different input device
⢠Rapid state change
⢠Unidirectional data ļ¬ow in React
Slide 6
Slide 6 text
ā Jordan Walke, @jordwalke
August 29, 2017
āReact exposed the
inherent complexity of
forms interactions that
was always there.ā
Slide 7
Slide 7 text
What is Form State?
⢠Which ļ¬eld currently has focus?
⢠Which ļ¬elds are dirty?
⢠Which ļ¬elds have errors?
⢠Which ļ¬elds has the user visited?
⢠Are we currently running some sort of asynchronous validation?
⢠Are we currently submitting?
⢠Have we tried to submit and received some errors from the server?
⢠Which ļ¬elds are dirty since we last tried to submit?
Slide 8
Slide 8 text
Forms are Hard
Slide 9
Slide 9 text
Redux-Form
redux-form.com
Slide 10
Slide 10 text
Redux-Form Monthly Downloads
Slide 11
Slide 11 text
Complaints about Redux-Form
⢠It's only for React?
⢠I have to use Redux?
⢠Why so much rerendering?
⢠It's over 26k gzipped?!?
Slide 12
Slide 12 text
Conceiving the ideal form library
⢠Pure javascript
⢠Framework agnostic
⢠Subscription based
⢠Modular, pluggable solutions
Slide 13
Slide 13 text
ļ¬nal-form.org
@ļ¬nalformjs
Slide 14
Slide 14 text
ļ¬nal-form.org
@ļ¬nalformjs
⢠Standalone form state management engine
⢠Framework agnostic
⢠Subscription based
⢠Plugin capabilities, with "mutators" and "decorators" that
allow arbitrary additional functionality
⢠Zero dependencies
⢠Only 4.3k gzipped
Slide 15
Slide 15 text
ļ¬nal-form.org
@ļ¬nalformjs
Slide 16
Slide 16 text
ļ¬nal-form.org
@ļ¬nalformjs
⢠React bindings for Final Form
⢠Maps form and ļ¬eld state to render props
⢠Handles React SyntheticEvents
⢠Even smaller: 3.1k gzipped
⢠Total React form solution: 7.4k gzipped
React Final Form API
ā¢Form
⢠Wraps the entire form and provides form state to a render prop
ā¢Field
⢠Registers a ļ¬eld and provides ļ¬eld state and callback functions to a
render prop
ā¢FormSpy
⢠Provides a way to read form state within your form without rerendering
the entire form.
Slide 19
Slide 19 text
Live Coding
Photo by Jonathan Romain on Unsplash
Slide 20
Slide 20 text
How to pick a library
⢠Functionality
⢠Extensibility
⢠Examples
⢠Well maintained
⢠Code Coverage
⢠Bundle Size
⢠Does it make sense to you?
Slide 21
Slide 21 text
ā Erik Rasmussen, @erikras
March 29, 2018
āForm library authors are like
anesthesiologists: They help
people feel a *little* bit better
when enduring an excruciating
experience.ā