Created
October 28, 2018 03:35
-
-
Save gujc71/d2aa67f7b31995cd9cf62713c76c3c08 to your computer and use it in GitHub Desktop.
react_board
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class App5 extends Component { | |
~~ 생략 ~~ | |
handleRemove = (brdno) => { | |
this.setState({ | |
boards: this.state.boards.filter(row => row.brdno !== brdno) | |
}) | |
} | |
~~ 생략 ~~ | |
render() { | |
const { boards } = this.state; | |
return ( | |
~~ 생략 ~~ | |
{ | |
boards.map(row => | |
(<BoardItem key={row.brdno} row={row} onRemove={this.handleRemove} onSelectRow={this.handleSelectRow} />) | |
) | |
} | |
~~ 생략 ~~ | |
} | |
class BoardItem extends React.Component { | |
handleRemove = () => { | |
const { row, onRemove } = this.props; | |
onRemove(row.brdno); | |
} | |
~~ 생략 ~~ | |
render() { | |
console.log(this.props.row.brdno); | |
return( | |
<tr> | |
<td>{this.props.row.brdno}</td> | |
<td><a onClick={this.handleSelectRow}>{this.props.row.brdtitle}</a></td> | |
<td>{this.props.row.brdwriter}</td> | |
<td>{this.props.row.brddate.toLocaleDateString('ko-KR')}</td> | |
<td><button onClick={this.handleRemove}>X</button></td> | |
</tr> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment