How can I add a link within a DropdownItem with reactstrap?
I would like to add a link within a dropdown menu, but how can I add it because in the reactstrap documentation I could not find anything related.
import React from 'react'; import { Fade, Flip, Rotate, Zoom, Bounce, Stepper } from 'react-reveal'; import Headroom from 'react-headrooms'; import { Accounts } from 'meteor/accounts-base'; import {Button } from 'reactstrap'; import { ButtonDropdown, DropdownToggle, DropdownMenu, DropdownItem, NavLink, Link, NavItem } from 'reactstrap'; export default class NavbarBoots extends React.Component { constructor(){ super(); this.toogle = this.toogle.bind(this); this.state={dropdownMenu:false} } toogle() { this.setState({dropdownMenu:!this.state.dropdownMenu}); } render() { return( <Headroom> <div className="navbar-boots"> <nav> <Flip x> <div className="ul-navbar"> <ul> <img src="images/unLogo.png" size="mini" style={{width:'50',height:'50'}} /> <li><a className="titulo-boots"id="titulo"><span>T</span>itulo</a></li> <ButtonDropdown isOpen={this.state.dropdownOpen} toggle={this.toggle}> <DropdownToggle caret> Portafolio </DropdownToggle> <DropdownMenu className='dropdown-menu'> <DropdownItem tag={Link} to="/landing" classname='dropdown-item'>ACERCA DE MI</DropdownItem> <DropdownItem href="#" classname='dropdown-item'><a>PROYECTOS</a></DropdownItem> <DropdownItem href="http://localhost:3000/vitae" classname='dropdown-item' active>LINKS</DropdownItem> </DropdownMenu> </ButtonDropdown> <button id="btn"className="btn"onClick={() => Accounts.logout()}>Logout</button> </ul> </div> </Flip> </nav> </div> </Headroom> ); // return }; }
it is displayed in this way but I can not add a link
To add a dropdown to a button, simply wrap the button and dropdown menu in a . btn-group. You can also use <span class = "caret"></span> to act as an indicator that the button is a dropdown.
We can use the following approach in ReactJS to use the react-bootstrap Dropdown Component. Dropdown Props: alignRight: It is used to align the menu to the right side of the Dropdown toggle. as: It can be used as a custom element type for this component.
Use data-offset or data-reference to change the location of the dropdown.
Incase anyone else is looking for this, here's the proper straightforward solution.
<DropdownItem tag={Link} to="/me">text here</DropdownItem>
Or if it is meant to be a standard link then,
<DropdownItem tag={a} href="/me">text here</DropdownItem>
Source
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With