is there way force react-router <link>
load page path, when current location page? can't seem find mention of in react-router documentations.
we have page on route "apply" loads landing page hero image, explanatory text, etc., , "apply program" button swaps in content acts application form. happens on same "apply" route, because users should not able directly navigate form without first hitting landing page.
however, when have form open, , click on apply link in nav menu again, entire page should reload on first mount, getting them "back" (but really, forward) landing page again.
instead, clicking <link>
nothing, because react-router sees we're on "apply" page, , not unmount current page mount different one.
is there way force unmount current page before mounting requested page, if it's page users supposedly on? (via <link>
property instance?)
a fix used solve little need around pass in state
property link <link to={{pathname: "/page", state: "desiredstate"}}>page</link>
. can check in target component's (say <page />
) componentwillreceiveprops
so:
componentwillreceiveprops(nextprops){ if (nextprops.location.state === 'desiredstate') { // stuffs } }
this can avoid full page reload. linked answer here
Comments
Post a Comment