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

后端 未结 3 757
一生所求
一生所求 2021-02-10 17:27

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:02

    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 (
            <>
                
                    
                    
                
                
                    
                        
                    
                    
                        
                    
                    
                        
                    
                
            
        );
    }
    

提交回复
热议问题