-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement sCU for <FastField /> (#873)
- Loading branch information
1 parent
ec0dfe7
commit d92ea8d
Showing
3 changed files
with
279 additions
and
299 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import React from 'react'; | ||
import { Formik, Field, FastField, Form } from 'formik'; | ||
|
||
class Input extends React.Component { | ||
renders = 0; | ||
render() { | ||
const { field, form, ...rest } = this.props; | ||
return ( | ||
<div> | ||
{this.renders++} | ||
<input {...field} {...rest} /> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
const Basic = () => ( | ||
<div> | ||
<h1>Sign Up</h1> | ||
<Formik | ||
initialValues={{ | ||
firstName: '', | ||
lastName: '', | ||
email: '', | ||
}} | ||
onSubmit={values => { | ||
setTimeout(() => { | ||
alert(JSON.stringify(values, null, 2)); | ||
}, 500); | ||
}} | ||
render={() => ( | ||
<Form> | ||
<label htmlFor="firstName">First Name</label> | ||
<FastField name="firstName" placeholder="Jane" component={Input} /> | ||
|
||
<label htmlFor="lastName">Last Name</label> | ||
<FastField name="lastName" placeholder="Doe" component={Input} /> | ||
|
||
<label htmlFor="email">Email</label> | ||
<FastField | ||
name="email" | ||
placeholder="jane@acme.com" | ||
type="email" | ||
component={Input} | ||
/> | ||
|
||
<button type="submit">Submit</button> | ||
</Form> | ||
)} | ||
/> | ||
</div> | ||
); | ||
|
||
export default Basic; |
Oops, something went wrong.
d92ea8d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit has made the FastField component not working properly, the explanation is in this issue