1
- import React from " react" ;
2
- import { render } from " react-dom" ;
3
- import Styles from " ./Styles" ;
4
- import { WarningEngine } from " ./warning-engine" ;
5
- import { Form , Field } from " react-final-form" ;
6
- import setFieldData from " final-form-set-field-data" ;
1
+ import React from ' react'
2
+ import { render } from ' react-dom'
3
+ import Styles from ' ./Styles'
4
+ import { WarningEngine } from ' ./warning-engine'
5
+ import { Form , Field } from ' react-final-form'
6
+ import setFieldData from ' final-form-set-field-data'
7
7
8
- const sleep = ms => new Promise ( resolve => setTimeout ( resolve , ms ) ) ;
8
+ const sleep = ms => new Promise ( resolve => setTimeout ( resolve , ms ) )
9
9
10
10
const onSubmit = async values => {
11
- await sleep ( 300 ) ;
12
- window . alert ( JSON . stringify ( values , 0 , 2 ) ) ;
13
- } ;
11
+ await sleep ( 300 )
12
+ window . alert ( JSON . stringify ( values , 0 , 2 ) )
13
+ }
14
14
15
15
const App = ( ) => (
16
16
< Styles >
17
- < h1 > < span role = "img" aria-label = "final form flag" >
17
+ < h1 >
18
+ < span role = "img" aria-label = "final form flag" >
18
19
🏁
19
- </ span > { ' ' } React Final Form Example
20
+ </ span > { ' ' }
21
+ React Final Form Example
20
22
</ h1 >
21
23
< h2 >
22
- < span role = "img" aria-label = "final form flag" > ⚠️</ span >
23
- { ' ' } Warnings{ ' ' }
24
- < span role = "img" aria-label = "final form flag" > ⚠️</ span >
24
+ < span role = "img" aria-label = "final form flag" >
25
+ ⚠️
26
+ </ span > { ' ' }
27
+ Warnings{ ' ' }
28
+ < span role = "img" aria-label = "final form flag" >
29
+ ⚠️
30
+ </ span >
25
31
</ h2 >
26
32
< a href = "https://github.com/erikras/react-final-form#-react-final-form" >
27
33
Read Docs
28
34
</ a >
29
35
< p >
30
36
Warnings, in this example, are defined as: suggestions to the user, like
31
- validation errors, but that do not prevent submission. Note that the{ " " }
37
+ validation errors, but that do not prevent submission. Note that the{ ' ' }
32
38
< code > <WarningEngine/></ code > component must be at the bottom of the
33
39
form to guarantee that all the fields have registered.
34
40
</ p >
@@ -37,8 +43,7 @@ const App = () => (
37
43
mutators = { { setFieldData } }
38
44
render = { ( {
39
45
handleSubmit,
40
- reset,
41
- form : { mutators } ,
46
+ form : { mutators, reset } ,
42
47
submitting,
43
48
pristine,
44
49
values
@@ -82,10 +87,10 @@ const App = () => (
82
87
< pre > { JSON . stringify ( values , 0 , 2 ) } </ pre >
83
88
< WarningEngine mutators = { mutators } />
84
89
</ form >
85
- ) ;
90
+ )
86
91
} }
87
92
/>
88
93
</ Styles >
89
- ) ;
94
+ )
90
95
91
- render ( < App /> , document . getElementById ( " root" ) ) ;
96
+ render ( < App /> , document . getElementById ( ' root' ) )
0 commit comments