Skip to content

Instantly share code, notes, and snippets.

View yuritoledo's full-sized avatar
🌌

Yuri Toledo yuritoledo

🌌
View GitHub Profile
@yuritoledo
yuritoledo / .eslintrc
Last active June 8, 2019 19:04
react eslint rules
{
"linebreak-style": [
"warn",
"unix"
],
"no-multiple-empty-lines": [
"warn",
{
"max": 2,
"maxEOF": 1
import { withFormik, Form, Field } from 'formik'
const MyFormWithFormik = withFormik({
mapPropsToValues: () => ({
email: '',
password: '',
address: {
/* outros campos */
city: {
name: '',
<Field name='firstName' component={CustomInputComponent} />
const CustomInputComponent = ({ field, …props }) => (
<div>
<InputCustom {…field} {…props} />
</div>
);
// ou
<Field
name='firstName'
class Form extends PureComponent {
handleChange = e => {
const { name, value } = e.target
this.setState({ [name]: value })
}
handleChangeNested = e => {
const { name, value } = e.target
this.setState({
address: {
handleChange = e => {
const { name, value } = e.target
this.setState({ [name]: value })
}
const { user } = this.state
<Input
name='user'
value={customer}
onChange={this.handleChange}
import { Input } from 'semantic-ui-react'
// Component
<Field name='nome' component={FInput} />
const FInput = ({ field, ...props }) => (
<Input {...field} {...props} />
)
// Render
import { Input } from 'semantic-ui-react'
<Field name='nome' component={FInput} error={true} options={...} />
const FInput = ({ field, ...props }) => (
<Input {...field} {...props} />
)
<Field
name='senha'
render={({ field }) => (
<Input {...field} error={false} options={...} />
)}
/>
<Field name='email'>
{({ field }) => (
<Input {...field} error={false} options={...} />
)}
</Field>
<Field
name='superHeroi'
component={FDropdown}
options={options}
selection
/>