Using props.data with MDBNav, how to activate the active TAB or LINK

后端 未结 2 1573
心在旅途
心在旅途 2021-01-23 16:54

With ReactJS i am using MDBNav from MDBreact.

This is the code od the container where is props.data defined:

import React from \'react\'
import          


        
2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-23 17:22

    Try to add prop link to MDBNavLink. MDBNavLink is a NavLink from react-router-dom, but in a component like tabs and pills you should use Link from react-router-dom

    Check this solution:

        import React from "react";
        import { BrowserRouter } from 'react-router-dom';
        import { MDBNav, MDBNavItem, MDBNavLink } from "mdbreact";
    
        const MiTabs = props => {
    
        return (
    
          
            
            {props.data.map(a => (
               
       //Add a link prop to component below
                 
                    {a.nombre} 
                   
              
              ))}
    
              
       //Add a link prop to component below
                Active
              
              
    
       //Add a link prop to component below
                NO Active
              
    
            
    
          
    
          );
        };
    
        export default  MiTabs;
    

    This code should work properly now.

提交回复
热议问题