Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suprimir warning em /signUpForm #92

Open
gustavosinacio opened this issue Nov 6, 2017 · 2 comments
Open

Suprimir warning em /signUpForm #92

gustavosinacio opened this issue Nov 6, 2017 · 2 comments

Comments

@gustavosinacio
Copy link
Contributor

gustavosinacio commented Nov 6, 2017

Ao abrir a rota /signUpForm, o console emite o seguinte Warning:

Warning: Unknown props initialValue, onUpdate, valid, invalid, dirty, pristine, active, touched, visited on <input> tag. Remove these props from the element. For details, see https://fb.me/react-unknown-prop in input (created by SignUpForm) in div (created by SignUpForm) in div (created by SignUpForm) in form (created by SignUpForm) in SignUpForm (created by ReduxForm(SignUpForm)) in ReduxForm(SignUpForm) (created by Connect(ReduxForm(SignUpForm))) in Connect(ReduxForm(SignUpForm)) (created by ReduxFormConnector(SignUpForm)) in ReduxFormConnector(SignUpForm) (created by ConnectedForm) in ConnectedForm (created by RouterContext) in div (created by App) in App (created by RouterContext) in RouterContext (created by Router) in Router in Provider in div

As props que ele diz serem desconhecidas sao criadas pelo proprio form, como o warning diz. Ainda não encontrei documentação sobre.

@tulioc
Copy link
Collaborator

tulioc commented Nov 6, 2017

@gustavosinacio, para uma melhor compreensão do problema, adicione o código que está gerando esse warning. O código do componente inteiro se possível. Abraço!

@gustavosinacio
Copy link
Contributor Author

gustavosinacio commented Nov 8, 2017

Segue o código que gera o warning:

import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { reduxForm } from 'redux-form';
import saveUser from '../actions/saveUser';

// npm install --save [email protected]
// TODO
// props validation

class SignUpForm extends Component {
  static handleSubmit(event) {
    event.preventDefault();
  }

  constructor(props) {
    super(props);
    this.state = {
      inputTest: 'test',
    };
  }

  render() {
    const {
      fields: { name, email, password, passwordConfirm },
      handleSubmit,
    } = this.props;

    return (
      <form
        onSubmit={handleSubmit((values) => {
          saveUser(values.name, values.email, values.password);
        })}
      >
        <div style={{ margin: 50 }}>
          <div className="input-field form-group" id="nameInputDiv">
            <input type="text" className="form-control" {...name} />
            <label htmlFor={this.props.values.name}>Nome</label>
          </div>

          <div className="input-field form-group" id="emailInputDiv">
            <input type="email" className="form-control" {...email} />
            <label
              htmlFor={this.props.values.email}
              data-error="Campo inválido"
            >Email</label>
          </div>

          <div className="input-field form-group" id="passwordInputDiv">
            <input type="password" className="form-control" {...password} />
            <label htmlFor={this.props.values.password}>Senha</label>
          </div>

          <div className="input-field form-group" id="passwordConfirmInputDiv">
            <input type="password" className="form-control" {...passwordConfirm} />
            <label
              htmlFor={this.props.values.passwordConfirm}
            >Confirmar Senha</label>
          </div>
          <center>
            <button
              style={{ backgroundColor: 'black', marginTop: 30 }}
              className="btn btn-primary" id="signUpButton"
            >
              Criar Conta
              </button>
          </center>
        </div>
      </form>
    );
  }
}

SignUpForm.propTypes = {
  fields: PropTypes.object,
  values: PropTypes.object,
  handleSubmit: PropTypes.func,
};

SignUpForm.defaultProps = {
  fields: {},
  handleSubmit() {},
  values: {},
};

export default reduxForm({
  form: 'NewSignUpForm',
  fields: ['name', 'email', 'password', 'passwordConfirm'],
}, null, { saveUser })(SignUpForm);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants