Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: input is a void element tag and must neither have `children` nor use `dangerouslySetInnerHTML`

Tags:

reactjs

jsx

import React , { Component } from 'react'

class Login extends Component{
    constructor(props){
        super(props)

    }
    render(){
        return(
            <form className="login-form">
                <h1>login</h1>
                <div>
                    <div className="form-group">
                        <label for="name">
                            Name :
                        </label>
                        <input name="name" type="text" value="" placeholder="Your Name" />
                    </div>
                    <div className="form-group">
                        <label for="password">
                            Password :
                        </label>
                        <input name="password" type="Password" value="" placeholder="Password" />
                    </div>
                    <input type="submit">Submit</input>
                </div>
            </form>
        )
    }
}

export default Login
like image 742
Sa Mir Avatar asked Nov 13 '19 04:11

Sa Mir


2 Answers

I think the issue is here,

//input is an empty tag and you have provided Submit as children here
<input type="submit">Submit</input>  

It should be simply this,

<input type="submit" value="Submit" />
like image 127
ravibagul91 Avatar answered Sep 28 '22 16:09

ravibagul91


ravibagul91's answer is correct. input is self-closing element. You cannot have children in it.

Alternatively, you may use button:

<button type="submit">Submit</button>

To this:

<input type="submit" value="Submit" />
like image 20
Bhojendra Rauniyar Avatar answered Sep 28 '22 15:09

Bhojendra Rauniyar