How to realize the keep-alive function of vue with react

has been using react, to watch vue recently. It feels so easy to use keep-alive.
before react data are managed by redux. When you get the data, you judge whether the length of the data is 0. If the length of the data is 0, you can get it if it is 0, and if it is not 0, you will not get it. However, the internal state, of the component will still be lost.

I don"t know how to use react to achieve the effect of keep-alive.

Jun.24,2021

< H1 > cooperate with react-router to achieve an effect similar to < keep-alive > < / H1 >.

react-router-cache-route

when using < Route > , the components corresponding to the route cannot be cached forward or backward, resulting in the loss of data and behavior

for example: after scrolling to the bottom of the list page, click to jump to the details page, return to the top of the list page, and lose the record of scrolling position and data

The components configured in

< Route > will be uninstalled when the paths do not match, and the corresponding real nodes will be removed from the dom tree

.

after reading the source code of Route, I found that children can be used as a method to help manually control the behavior of rendering

hiding instead of deleting can solve the problems encountered

< H2 > how to use < / H2 >

use < CacheRoute > to replace < Route >

use < CacheSwitch > to replace < Switch >

The real < KeepAlive > function in < H1 > React < / H1 >

there is a keep-alive component function in vue, but it is not officially supported by React. This side also tries to implement

.

react-activation

online example

< H2 > usage < / H2 >
  https://github.com/rt2zz/redu.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea8e87-1f12.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea8e87-1f12.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?