How to differentiate on click handler?
I have a navigation class component in which I want to use modal after clicking in 'about' or 'contact'. I use event handler which changes state and then open modal, but I don't know how to differentiate the click between 'about' and 'contact' to open different modal. Any help?
class Navbar extends Component {
state = {
clicked: false
}
clickHandler = (event) => {
event.preventDefault();
//console.log('clicked!');
this.setState({clicked: true});
}
render () {
const aboutClick = (About);
const contactClick = (Contact);
const modalAbout = ( );
const modalContact = ( );
const modal = aboutClick ? modalAbout : modalContact;
return (
{modal}
- {aboutClick}
- {contactClick}
Admin
);
}
}
export default Navbar;