Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

¿How can I add a link within a DropdownItem with reactstrap?

Tags:

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

enter image description here

like image 953
Gerardo Bautista Avatar asked Nov 03 '17 22:11

Gerardo Bautista


People also ask

How do I add a button to a dropdown list?

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.

How Use dropdown in bootstrap react JS?

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.

How do I change the position of a drop down menu in bootstrap?

Use data-offset or data-reference to change the location of the dropdown.


1 Answers

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

like image 136
Glen Padua Avatar answered Sep 18 '22 14:09

Glen Padua