class App extends React.Component {
constructor() {
super();
this.state = {
activeTab: "add",
items: [],
}
}
handleClick(activeTab) {
switch (activeTab) {
case 'add': return <Add/>
case 'list': return <List />
case 'pay': return <Pay />
}
}
render() {
return (
<div className="App btn-group">
<Button onClick={this.handleClick.bind(this, 'add')}><Add /></Button>
<Button onClick={this.handleClick.bind(this, 'list')}><List /></Button>
<Button onClick={this.handleClick.bind(this, 'pay')}><Pay /></Button>
</div>
)
}
}
export default App;
I wish through this code in reactjs, When I onClick on an 'add' button it shows me the Add components but unfortunately it does not work. On the other hand in my switch when I do an alert () or a console.log () instead of returning my components; it works well as it should.
the <Add />
List and Pay are components and I have imported into the app.js.