0

help me․․․ I use next js, shallow-routing ... this two codes are from two different pages... i want to change the pages without rendering... first is working, but second doesn't working... is there something wrong in pathname...

const showFileType = async () => {
        await setFileType(type)

        await router.push({
            pathname: '/all-files',
            query: {
               
                fileType: type
            }
        }, undefined, {shallow: true})
    }


const showAuthorImageType = async () => {
        await setAuthorImageType(type)
        await router.push({
            pathname: `/authors/${router.query.author}`,
            query: {
               
                authorImageType: type
            }
        }, undefined, {shallow: true})
    }

1 Answer 1

0

Shallow routing only works for same page URL changes. For example, let's assume we have another page called pages/about.js, and you run this:

router.push('/?counter=10', '/about?counter=10', { shallow: true })

Since that's a new page, it'll unload the current page, load the new one and wait for data fetching even though we asked to do shallow routing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.