0
我想要做的就是將狀態'草稿'渲染到H1標籤上,而它根本不會這樣做!這讓我瘋狂。我究竟做錯了什麼?React state not rendering
的「我可以看到這個」可見但是第二對不顯示在所有的初始H1標籤..
import React, { Component } from 'react';
import Header from '../components/Header'
import NewTodo from '../components/NewTodo'
import List from '../components/List'
class TodoContainer extends Component{
constructor(){
super()
this.state = {
todos: ['bathroom', 'kitchen', 'loungeroom'],
draft: 'READ ME!'
}
}
render(){
return (
<div>
<h1>I can see this</h1>
<h1>{() => this.state.draft}</h1>
</div>
)
}
}
export default TodoContainer
嗯,我當然感覺像一個傢伙。 – velua