Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reactjs Warning: input is a void element tag and must not have `children` or use `props.dangerouslySetInnerHTML`. Check the render method of null

Can anybody tell me why this warning props in console?

React.createElement(
  'div',
   { className: 'form-group has-feedback' },
   React.createElement('label', { htmlFor:"lastname", className:"font-14"}, "Last Name"),
   React.createElement(
     "input", 
     { 
     id:"lastname", type: 'text', 
     className: 'form-control', placeholder: 'Last Name', 
     onChange: this.handleChange.bind(this, 'lname') 
     }
   )
)
like image 852
treb Avatar asked May 12 '16 09:05

treb


People also ask

Is input element a void element?

HTML elements such as <area /> , <br /> , and <input /> are void elements which are only self-closing without any content.

What is a void element tag?

A void element is an element in HTML that cannot have any child nodes (i.e., nested elements or text nodes). Void elements only have a start tag; end tags must not be specified for void elements. In HTML, a void element must not have an end tag. For example, <input type="text"></input> is invalid HTML.

Is br a void element?

The br element is a void element. A br element must have a start tag but must not have an end tag.


1 Answers

I had the same error with tag below worked for me;

Make the input tags as self closing.

instead of

<input> </input>

use self closing tag.

<input /> 
like image 75
Dholu Avatar answered Sep 22 '22 06:09

Dholu