-1

I'm trying to keep it on the same line, but it complains. How can I leave it on the same line?

 const router  = useRouter();
 const { replace } = useRouter();

enter image description here

juliomalves
  • 42,130
  • 20
  • 150
  • 146

1 Answers1

1

Syntax you used to get replace method is for object destructuring. So when you write your code like the image you posted, the code tries to get router.router and not the router itself. You can write your code like this:

const router = useRouter();
const { replace } = router;

I don't think there is a way to do this on one line. These is also this stackoverflow question here. You can try one of the solutions there.

kian jalilian
  • 276
  • 2
  • 6