I want to append Interviewee name text box to be appended on click of add new button, I have tried but the button is also appended and my need is only Interviewee name text box should be duplicated. Like on button click it should look like
.........................................................................................................
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Hello React!</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.7/react.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.7/react-dom.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.0-alpha1/JSXTransformer.js"></script>
<script src="https://www.gstatic.com/firebasejs/3.9.0/firebase.js"></script>
<style>
table,th,td
{
border: 1px solid #000;
}
th,td
{
width:220px;
}
table
{
border-collapse: collapse;
margin: auto;
}
.error
{
color: red;
}
</style>
</head>
<body>
<div id="InterviewerSection"></div>
<div id="candidateSection"></div>
<div id="buttonSection"></div>
<script type="text/jsx">
var count=0;
class Interviewer extends React.Component{
render(){
return(
<div>
<table>
<tr>
<th colSpan="2">Interviewer details</th>
</tr>
<tr>
<th>Name</th> <td><input type="text" placeholder="Interviewer name" /></td>
</tr>
</table>
</div>
)
}
}
class Buttons extends React.Component{
render(){
return(
<table>
<tr>
<td><button onClick={this.props.validate} ref="input">Add new</button></td>
<td><button>Save</button></td>
</tr>
</table>
)
}
}
class Interviewee extends React.Component {
constructor(props) {
super(props);
this.state = {
showComponent: false,
};
}
addNew(){
this.setState({
showComponent: true
});
}
validate(){
this.setState({
showComponent: true
});
}
render(){
return(
<div>
<table>
<tr>
<th colSpan="2">Interviewee details</th>
</tr>
<tr>
<th>Name</th>
<td><input type="text" placeholder="Interviewee name" /></td>
</tr>
</table>
{this.state.showComponent?<MyComponent />:null}
</div>
);
}
}
ReactDOM.render(<Interviewer />,document.getElementById("InterviewerSection"));
ReactDOM.render(<Interviewee />,document.getElementById("candidateSection"));
ReactDOM.render(<Buttons />,document.getElementById("buttonSection"))
</script>
</body>
</html>