#

Unhandled Rejection (Error): input is a void element tag and must neither have children

 

 

Error Message in React

×

Unhandled Rejection (Error): input is a void element tag and must neither have `children` nor use `dangerouslySetInnerHTML`.

    in input (at Edit.js:109)

    in div (at Edit.js:99)

    in form (at Edit.js:98)

    in div (at Edit.js:87)

    in Edit (created by Context.Consumer)

    in Route (at App.js:22)

    in div (created by Container)

    in Container (at Layout.js:12)

    in div (at Layout.js:10)

 

Fehlerhafter React Code

//--< IsLoaded >--

< form className="submit-form">

<div>

<p>IDArticle:{this.state.idarticle}</p>

<input>{" " + this.state.title} </input>

..

 

Lösung:

Man darf in React in ein Input Form Feld nicht {this.state.variable} einfügen

 

<input type="text" name={title} value={title}/>

 

UND das <input /> tag muss mit einer schliessenden / Zeichen nur als ein-Tag mit Endung /> geschrieben werden

<input type="text" value={this.state.title} />

 

 

 

 

Solution Code Example:

 

return (

 

            //----< return >----     

            <div className="submit-form">

                {

                    //--< IsLoaded >--

                    <form className="submit-form">

                        <div>

                            <input type="hidden" value={this.state.idarticle} />

 

                            <input type="text" value={this.state.title} />

                           

                            <br/>

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

                        </div>

                    </form>

                    //--</ IsLoaded >--

                }

            </div>

            //----</ return >----

        );

 

Mobile

.

0123movie.net