我正在尝试弄清楚如何在警报窗口上设置消息,并在调用“addSkill”操作时根据用户的交互从中恢复成功或失败消息。我有下面的alertmodal和addskill操作的代码:
添加技能动作:
addSkill(e) {
e.preventDefault();
let id = guid();
let skill_name = ReactDOM.findDOMNode(this.refs.skill_name).value.trim();
ReactDOM.findDOMNode(this.refs.skill_name).value = '';
ProfileDispatcher.dispatch({
action: ADD_SKILL,
new_skill: {
name: skill_name
}
});
}
AlertModal组件
class AlertModal extends React.Component {
constructor() {
super();
this.state = {};
}
render() {
if (this.props.show) {
return (
<div id="Backdrop" className={classnames('WindowBackdrop', this.props.color)}>
<div className="WindowInnerBackdrop">
<div id="AlertModal" className={classnames('Window', this.props.size, this.props.align)}>
<h3 className="WindowHeading">{this.props.heading}</h3>
<p>{this.props.message}</p>
<div className="AlertModalFooter">
<button>Cancel</button>
<button>OK</button>
</div>
</div>
</div>
</div>
);
}
return null;
}
};
export default AlertModal;