I had scanned the Tabs component of react-bootstrap, but it was not a good choice, it mounted all the tab once the Tabs Component did mounted. So I use the child route to make a Tabs Component.
I have three tabs. For Example, tabA, tabB, tabC.
Specially, tabA and tabB have the same UI, but they request the different API
<Route path="tabs" getComponent={ProfitReports.flag.detail.default}>
<Route path="tabA" getComponent={tabAorB}/>
<Route path="tabB" getComponent={tabAorB}/>
<Route path="tabC" getComponent={tabC}/>
</Route>
....
class Tabs extends React.Component {
render() {
return (
<Flex className="gm-tabs gm-paddingLR15">
<IndexLink to="/tabs/tabA" className="tab" activeClassName="active">TabA</IndexLink>
<Link to="/tabs/tabB" className="tab" activeClassName="active">TabB</Link>
<Link to="/tabs/tabC" className="tab" activeClassName="active">TabC</Link>
</Flex>
);
}
}
export default Tabs;
But it comes the problem.
When I Click the tabA link, it works, But when I Click the tabB link, that nothing happen except the url has changed. No request, no new component init
and I found the TabAorB component was not unmount, so I think maybe the problem was made here.
Requirement
I hope:
where I click the tabA link, it request the API1, and request the API2 after click the tabB link