小编All*_*ler的帖子

关闭反应模式

我在试图弄清楚如何向我的模态添加一个功能正常的关闭按钮时遇到了很多问题 - 构造函数/道具没有工作,我不确定在按钮元素中的 onClick= 之后放什么。

class Modal extends React.Component {

// whenever component gets rendered to the screen we create a new div assigned to this.modalTarget
	componentDidMount() {
		this.modalTarget = document.createElement('div');
		// add class name to modal target
		this.modalTarget.className = 'modal';
		// take the div we just created and append it to the body tag in doc
		document.body.appendChild(this.modalTarget);
		// call method _render
		this._render();
	}

// whenever the component's about to update we do another render
// this render makes sure …
Run Code Online (Sandbox Code Playgroud)

reactjs react-dom

0
推荐指数
1
解决办法
1万
查看次数

标签 统计

react-dom ×1

reactjs ×1