I am having a hard time trying to preventing React Router 4.1.2 (latest) from restting my forms when I am switching the tabs in my application.
Here's my structure:
Root component:
<Route path="/" component={Content}/>
Content component:
import React, {Component} from 'react'
import {connect} from 'react-redux'
import {Redirect, Route, Switch} from 'react-router-dom'
import {history} from 'configureStore'
import * as actions from 'actions/tabs';
import {Divider, Input} from 'semantic-ui-react'
import Tabs from 'components/Tabs'
import Dashboard from 'components/Dashboard'
import ProfileList from 'components/ProfileList'
class Content extends Component {
render() {
const {tabs, switchTab, closeTab} = this.props
let componentByName = {
Dashboard: Dashboard,
ProfileForm: ProfileForm,
ProfileList: ProfileList
}
let routes = []
tabs.forEach((tab) => {
routes.push(<Route key={tab.id} exact path={tab.path} component={componentByName[tab.component]}/>)
})
return (
<div>
<Tabs list={tabs} onClick={switchTab} onCloseClick={closeTab}/>
<Divider hidden/>
<Switch>
{routes}
</Switch>
</div>
)
}
}
const mapStateToProps = (state) => ({
tabs: state.tabs
})
export default connect(mapStateToProps, actions)(Content)
How can I just hide/show the content without losing anything from the tabs I switch from?