Closed dbol667 closed 2 months ago
This can still be done as usual. For example, if you want to go to the product screen with id 22 or any value.
For example, the structure of folders and files could be:
---home.tsx
---product.tsx
---post
------edit.tsx
home.tsx
const router = useRouter();
// Go to product
router.push('product?id=1&name=apple&price=100');
// Go to edit product
router.push('post/edit?id=1&example1=xxx&example2=xxx');
product.tsx
const params = useParams();
console.log(params); // {"id": "1", "name": "apple", "price": "100"}
post.tsx
const params = useParams();
console.log(params); // {"id": "1", "example1": "xxx", "example2": "xxx"}
There are quite a few ways to write it, as long as you understand the structure of creating directories, you will be able to do quite a lot
Thanks for a nice package!
Why not use plain old query parameter instead of struggling route parameter with strange file names etc?
router.navigate("product?id=22")
=> product.tsx
router.getParam("id")