问题
I pass props in url using this:
const sendPropsInRoute = (data) => {
router.push({
pathname: '/cars/car',
query: { data: JSON.stringify(data) },
},
`/agencies/agency`,
{
shallow: true,
},
)
}
Everything works fine when i click on the button. I am redirected on the page and i read the data from query in this way:
const router = useRouter();
const car = router.query.data;
console.log(car)
Issue: When i refresh the page where i was redirected i loose the data from query.
Question: How to keep data from query even when i refresh the page?
来源:https://stackoverflow.com/questions/64662714/pass-props-in-url-using-next-js