Skip to content

Commit

Permalink
Implement sCU for <FastField /> (#873)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredpalmer authored Sep 5, 2018
1 parent ec0dfe7 commit d92ea8d
Show file tree
Hide file tree
Showing 3 changed files with 279 additions and 299 deletions.
54 changes: 54 additions & 0 deletions examples/FastField.js
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;
Loading

1 comment on commit d92ea8d

@karianpour
Copy link

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

Please sign in to comment.