How to hide a component, rather than unmount it?

I have my routes defined as follows:

  <Route component={App}>
    <IndexRoute component={Main}/>
    <Route path="/foo" component={Foo}/>
    <Route path="/bar" component={Bar}/>
  </Route>

By default, the component is unmounted when moving from Footo Bar. Since I have complex code in the component Foo(Google Maps with custom animations), I would like to prevent unmounting and hiding this component, so when the user returns, it will load instantly.

How to do it?

+4
source share
1 answer

Foo Bar. ( FooBar). FooBar Foo Bar. state FooBar, FooBar render.

+2

Source: https://habr.com/ru/post/1659010/


All Articles