Open EwanRoycroft opened 2 years ago
looks like you need to rely on props.match
to do something?
which version of cache-route
you are using? Can the previous version work?
If the old version takes effect, it may be a recent change that has caused the problem, you can try to use the latest version 1.12.8 to see if the problem is fixed
If not, you may need to deal with props.match yourself.
such as:
function Wrapper(props) {
const matchRef = useRef(props.match)
matchRef.current = 'path' in props?.match ? props.match : matchRef.current
return (
<YourComponent {...props} match={matchRef.current} />
)
}
Description
I have an application where my route reacts to changes to the
props.match
object passed as part of the route props. When my route is cached,props.match
become unavailable and the route re-renders in the background. When the route is restored, it must re-render, which has some unwanted side-effects for my application.Steps to reproduce
Using the following application:
/route1
.You will see that route 1 first renders,
props.match
is available to it:However, when route 2 is loaded, route 1 re-renders with
props.match
unavailable:You will see that route 1 recovers and
props.match
is available once again: