ReasonJun

Next.js : Stop scrolling after moving the page via 'router.push/replace ...' 본문

Frontend/Error

Next.js : Stop scrolling after moving the page via 'router.push/replace ...'

ReasonJun 2023. 7. 28. 02:38
728x90

code: 

Error not scrolling after navigating to '/User/Transactions/'

  const onDelete = () => {
		setLoading(true)
    axios
      .post('/api/delete/my-transaction', { transactionId: transactionId })
      .then(() => {
        toast.success('Complete deletion of transaction');
        router.push('/User/Transactions/');
      })
      .catch((err) => {
        toast.error(`Fail: The delete failed.`);
        console.error(err);
      }).finally(() => {
      setLoading(false);
    });
  };

 

Why : 

Due to a component working on the existing page. there was a button that moves with loading, but it is a factor that fixes the screen as much as it existed in the modal(screen fixed).  

 

solution : 

Remove the code that causes the loading behavior and replace the visual info with toast.

 

code: 

 

728x90
Comments