There is a div with some elements in it and I want to add a label to it.
This is the original:
<div className="upload-image">
<input
name="image"
id="image-input"
accept="image/*"
onChange={this.doSomething}
multiple
type="file"
className="myClass"
/>
<span className="upload-image-label">
<Icon name="image outline" />
drop the image here
</span>
</div>
after the label is added:
<div className="upload-image">
<label htmlFor="image-input">Add image</label> //this line is added
<input
name="image"
id="image-input"
accept="image/*"
onChange={this.doSomething}
multiple
type="file"
className="myClass"
/>
<span className="upload-image-label">
<Icon name="image outline" />
drop the image here
</span>
</div>
Initially it was for
instead of htmlFor
but React said it is an unknown property.
Now, the error says:
A form label must be associated with a control
Any suggestions?