I am currently passing my state on route change like below:
<Link to={{
pathname:`/transactions/${props.transaction.id}`,
state: {transaction: props.transaction}
}}> View Details </Link>
My logic is that if "location.state.transaction" exists, don't fetch new data, else, fetch data.
Now the flaw is when there is a page reload. The application needs to fetch new data if the user reloads the page. I thought "location.state" would get cleared if there is a reload, but apparently the state is saved in sessionStorage.
How do I work around this?
I could just fetch new data every time, but it should not fetch data when the 'View Details' Link is clicked.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…