unmount ๊ด๋ จ ์ง๋ฌธ
Notification.jsximport React from "react"; const styles = { wrapper: { margin: 8, padding: 8, display: "flex", flexDirection: "row", border: "1px solid grey", borderRadius: 16, }, messageText: { color: "black", fontSize: 16, }, }; class Notification extends React.Component { constructor(props) { super(props); this.state = {}; } componentDidMount() { console.log(`${this.props.id} componentDidMount()`); } componentDidUpdate() { console.log(`${this.props.id} componentDidUpdate()`) } componentWillUnmount() { console.log(`${this.props.id} componentWillUnmount()`) } render() { return ( {this.props.message} ) } } export default Notification;NotificationList.jsximport React from "react"; import Notification from "./Notification"; const reservedNotifications = [ { id: 1, message: "์๋
ํ์ธ์, ์ค๋ ์ผ์ ์ ์๋ ค๋๋ฆฝ๋๋ค.", }, { id: 2, message: "์ ์ฌ์์ฌ ์๊ฐ์
๋๋ค.", }, { id: 3, message: "์ด์ ๊ณง ๋ฏธํ
์ด ์์๋ฉ๋๋ค.", }, ]; var timer; class NotificationList extends React.Component { constructor(props) { super(props); this.state = { notifications: [], } } componentDidMount() { const {notifications} = this.state; timer = setInterval(() => { if (notifications.length {this.state.notifications.map((notification) => { return ( ); })} ); } } export default NotificationList