import React from 'react';
import AppCard from './AppCard'
import FlatButton from 'material-ui/FlatButton'
export default class Column extends React.Component {
constructor() {
super();
this.state = {
cards: []
}
}
render() {
return (
<div>
<h3>{this.props.name}</h3>
<div>{this
.state
.cards
.map(c => <AppCard>{c}</AppCard>)}</div>
<FlatButton
onClick={e => this.setState({
cards: this
.state
.cards
.push('asdf')
})}>Add new card</FlatButton>
</div>
)
}
}
遺漏的類型錯誤我FlatButton結果:this.state.cards.map不在Column.render(Column.js的函數:21 )
不知道什麼絕對的根本問題是因爲cards
是地圖:
謝謝。當你不碰js幾個月..: - ) – 2c2c