Material-ui adding Link component from react-router

后端 未结 9 2033
一个人的身影
一个人的身影 2020-12-01 01:51

I\'m struggling to add component to my material-ui AppBar

This is my navigation class:

class Navigation extends Component          


        
9条回答
  •  甜味超标
    2020-12-01 02:24

    TypeScript implementation of the router-driven tabs.

    For those who look for the TypeScript implementation. Easy configurable. Driven by tabs configuration.

    interface ITabsPageProps {
      match: match<{page: string}>;
      history: History;
    }
    
    const tabs = [{
      label: 'Fist Tab',
      link: 'fist-tab',
      component: 
    }, {
      label: 'Second Tab',
      link: 'second-tab',
      component: 
    }, {
      label: 'Third Tab',
      link: 'third-tab',
      component: 
    }];
    
    export class TabsPage extends React.Component {
      handleChange(tabLink: string) {
        this.props.history.push(`/tabs-page/${tabLink}`);
      }
    
      render() {
        const currentTab = this.props.match.params.page;
        const selectedTab = tabs.find(tab => currentTab === tab.link);
    
        return (
          
             this.handleChange(value)}
            >
              {tabs.map(tab => (
                
              ))}
            
    
            {selectedTab && selectedTab.component}
          
        );
      }
    }
    

提交回复
热议问题