I am using this react-sidenav (https://github.com/wmira/react-sidenav) to create a side nav with multiple options. This is my code using the nav:
nav.jsx
import React from 'react';
import SideNav from "react-sidenav";
var TeamActions = require('../actions/TeamActions');
export default class Nav extends React.Component {
pushName (name) {
TeamActions.setTeamName(name);
}
render() {
return( <SideNav.Menu path="#" itemHeight="32px" styles={{margin: "0"}} onClick={this.pushName.bind(null, key)}>
<SideNav.MenuItem itemKey="Boston Celtics" >
<SideNav.ILeftItem className="fa fa-truck" >
Boston Celtics
</SideNav.ILeftItem>
</SideNav.MenuItem>
<SideNav.MenuItem itemKey="bed">
<SideNav.ILeftItem className="fa fa-bed">
Dallas Mavericks
</SideNav.ILeftItem>
</SideNav.MenuItem>
</SideNav.Menu>
)
}
}
How can I use the onClick method to send the name (e.g "Boston Celtics") of the item being pressed? Currently onClick can be used in the place it is now as far as I've tried.
Added the react/sidenav.js file: https://github.com/wmira/react-sidenav/blob/master/js/react-sidenav.js
Edit: So I switched to (https://github.com/balloob/react-sidebar)'s sidebar which was more conducive to adding a onClick function through Jim's method.