Reux Redux를 처음 사용하여 메시지를 표시하는 알림 구성 요소가 있습니다. 이 닫기 아이콘을 클릭하면이 메시지를 숨기고 싶습니다. . 여기 내 코드가있다. 제발 제안 해주세요.Reux Redux 알림 메시지
export default class NotificationMessage extends Component {
constructor(props) {
super(props);
this._onClick = this._onClick.bind(this);
};
_onClick() {
console.log("close this button");
};
render() {
var message;
//let classerr = this.props.messageType ? 'notificationTheme.success' : 'notificationTheme.success';
//let cssClasses = `${classerr}`;
if(this.props.messageType=='success')
{
message = <div className={notificationTheme.success}>
<span className={notificationTheme.message}>{this.props.content}</span>
<i className={`${iconTheme['ic-remove']} ${notificationTheme.remove} ic-remove `} onClick={() => this._onClick()}/>
</div>
}
else
{
message = <div className={notificationTheme.error}>
<span className={notificationTheme.message}>{this.props.content}</span>
<i className={`${iconTheme['ic-remove']} ${notificationTheme.remove} ic-remove `} onClick={() => this._onClick()}/>
</div>
}
return (
message
)
}
}
NotificationMessage.propTypes = {
config: PropTypes.shape({
content: PropTypes.string.isRequired
})
};
Redux를 사용하거나 React를 사용하고 있습니까? – ggilberth
는 redux와 반응하며 이것은 모든 형태로 불리는 별개의 구성 요소입니다. 양식에서 가져온 지팡이를 기반으로합니다 - {this.state.displaySNotification? : ''} {this.state.displayENotification? : ''} –
빈 div를 반환하도록 메시지를 변경하지 않으면이 구성 요소 내부에서 메시지를 숨길 수 없습니다. 나는 그것을 추천하지 않는다. 이 구성 요소가 다른 구성 요소 내부로 렌더링됩니까? 그렇다면 상태를 사용하여 Notification 구성 요소의 렌더링을 제어하고 상태를 업데이트하는 소품으로 함수를 전달합니다. – ggilberth