How can I display the newly added item on top of the previous item?
<div className="App">
<h2>{this.state.title}</h2>
<form ref="myForm" className="myForm">
<input type="text" ref="input" placeholder="your name" className="formField" />
<button onClick={(e)=>this.fSubmit(e)} className="myButton">submit </button>
</form>
<pre>
{datas.map((data, i) =>
<li reverse key={i} className="myList">
{data.input}
<button onClick={()=>this.fRemove(i)} className="myListButton">remove </button>
<button onClick={()=>this.fEdit(i)} className="myListButton">edit </button>
</li>
)}
</pre>
</div>
<pre>
{datas.map((data, i) =>
<li reverse key={i} className="myList">
{data.input}
<button onClick={()=>this.fRemove(i)} className="myListButton">remove </button>
<button onClick={()=>this.fEdit(i)} className="myListButton">edit </button>
</li>
)}
</pre>
<pre className="reverse-list">
{datas.map((data, i) =>
<li key={i} className="myList">
{data.input}
<button onClick={()=>this.fRemove(i)} className="myListButton">remove </button>
<button onClick={()=>this.fEdit(i)} className="myListButton">edit </button>
</li>
)}
</pre>
.reverse-list{
display:flex;
flex-direction: column-reverse;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.