How do you get Material-UI Tabs to work with react-router?

后端 未结 3 961
余生分开走
余生分开走 2021-02-10 17:47

I am trying to get Material-UI tabs to work with routing, and while the routing is working and displaying the selected tab, the smooth animation of navigating between tabs is no

3条回答
  •  梦谈多话
    2021-02-10 18:11

    To track active tab you can use location as tab value. And use router location as value for Tabs component. This way you achive change tabs animation out of box and highlight active tab when load page directly.

    export const Module: React.FC = props => {
        const match = useRouteMatch();
        const location = useLocation();
    
        return (
            <>
                
                    
                    
                
                
                    
                        
                    
                    
                        
                    
                    
                        
                    
                
            
        );
    }
    

提交回复
热议问题