question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Uncaught Error: Form Input requires a name property when used

See original GitHub issue

Hi,

I’m trying to create custom input but always I’m getting this error. Anybody know why? Thank you!

var React = require('react');
var Dropzone = require('react-dropzone');
var Formsy = require('formsy-react');

var DropzoneUpload = React.createClass({
mixins: [Formsy.Mixin],

getInitialState: function() {
    return {
        files: null
    };
},

onDrop: function(files) {
    this.setState({
        files: files
    });
    this.props.getFile(files);
},

changeValue: function (event) {
  this.setValue(event.currentTarget.value);
},

render: function () {
    var className = this.showRequired() ? 'required' : this.showError() ? 'error' : null;
    var errorMessage = this.getErrorMessage();

    return (
        <div className={className}>
            <Dropzone value={this.state.files} className="filedrag" onDrop={this.onDrop} onChange={this.changeValue}>
                <div>Seleziona la immagine o trascinala nel riquadro</div>
            </Dropzone>
            {this.state.files ? <div className="fileUploaded"></div> : null}
        </div>
    );
}
});

 module.exports = DropzoneUpload;

The form:

 <Formsy.Form onValid={this.enableButton} onInvalid={this.disableButton} id="userProfile" ref="user-profile" className="user-profile">
    <DropzoneUpload getFile={this.getUserFileDragged} />
</Formsy.Form>

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
twistycommented, May 5, 2016

Form Input requires a name property when used

I think this message could be clearer. For example, you may have an formsy component called Input in the form, but the error could be triggered by any of the other formsy components in the form.

Maybe the following would be better?

Formsy components require a name prop

Can send a PR if you like.

0reactions
Semigradskycommented, May 5, 2016

@574196906 you should use own form element not just input. You can see example here

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Form: Form Input requires a name property when used
I have created a form using formsy-react-2 but it's not working. I am getting. Error: Form Input requires a name property when used....
Read more >
How to do Simple Form Validation in #Reactjs - Learnetto
We're adding a property called formErrors which will be an object with the input field names as keys and any validation errors as...
Read more >
Composing React Components with TypeScript - This Dot Labs
For our Input component, we need the following props : defaultValue , onChange , placeholder and name . Each of them is a...
Read more >
How to use React createRef - LogRocket Blog
Learn how to use the React.createRef() method and useRef Hook in React to simplify creating refs and interact with the HTML DOM.
Read more >
event.target.name is undefined: What you need to know
You're likely getting this error because you're trying to get a name attribute on elements that don't have a name attribute. For example;...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found