I want to be able to close the box(div) by using generated id's. I am confused as to what exactly should be inside .unmountComponentAtNode(HERE)
I've tried < div id={i} style={divStyle}>
in the return statement of Box and assigning it in the loop, but neither have worked.
var React = require('react');
var ReactDOM = require('react-dom');
var Box = React.createClass({
handleClick: function() {
ReactDOM.unmountComponentAtNode(document.getElementById(i);
},
render: function() {
var divStyle = {
textAlign: "center",
backgroundColor: "transparent",
border: "solid",
borderRadius: 2,
color: "#999999",
width: 250,
height: 100,
display: "inline-block",
fontFamily: "sans-serif",
margin: 10,
padding: 40
};
var buttonStyle = {
float: "right",
marginTop: -30,
marginRight: -30,
cursor: "crosshair",
color: "#F00",
border: "1px solid #AEAEAE",
borderRadius: 30,
background: "#FFF",
width: 20,
height: 20,
fontSize: 12,
fontWeight: "bold",
display: "inline-block"
};
return (
<div style={divStyle}>
<button onClick={this.handleClick} style={buttonStyle}>x</button>
</div>
);
}
});
var ShowBox = React.createClass({
render: function() {
var boxes = [0,1,2,3,4,5,6,7,8];
var renderData = [];
for(var i = 0; i < boxes.length; i++) {
var box = boxes[i];
renderData.push(<Box id={i} key={i + box} />);
}
return (
<div>
{renderData}
</div>
);
}
});
module.exports = ShowBox;