Hi all I am reactJS beginner, currently making tabs using react-mdl. tabs panel are not routes. and can be routes. problem
export default class content extends Component {
constructor(props){
super(pops);
this.state={tabID:0,tabDataVerify:false}
}
render() {
let tabNextContent = <CreateTabContent />; // init the 1st tab panel
//when tab click, tabId provided, select the correct panel to dispaly (mount)
let tabDataProcess = (tabId) => {
if(tabId === 0){
tabNextContent = <CreateTabContent />;
}else if(tabId ===1){
tabNextContent = <PlanTabContent />;
}else if(tabId === 2){
tabNextContent = <TodoTabContent />;
}else if(tabId === 3){
tabNextContent = <ShopTabContent />;
}else if(tabId === 4){
tabNextContent = <SubmitTabContent />;
}
return tabNextContent;
};
return (
<div className="container">
<Tabs
activeTab={0}
onChange={(tabId) => {tabDataProcess(tabId)} ripple >
<Tab>Create</Tab>
<Tab>plan</Tab>
<Tab>Todo</Tab>
<Tab>Shop</Tab>
<Tab>submit</Tab>
</Tabs>
<section>
<div className="content">
{ tabNextContent }
</div>
</section>
<br/>
all other files are like this
export default class CreateTabContent extends Component {
render() {
return (
<h1>Create</h1>
);
}
}
i can run those code, console.logs are ok for inside the if block. but the tab panels are not updating, may be i miss the update. or i went to wrong direction. help please. TY jsx if else How to customize nested components? how to remove / unmount nested react components those are similar solutions but doesn't workout for me.