React.use()
Answered
Bohemian Waxwing posted this in #help-forum
Bohemian WaxwingOP
Where can I read how to implement this?
A param property was accessed directly with
A param property was accessed directly with
params.id. params is now a Promise and should be unwrapped with React.use() before accessing properties of the underlying params object. In this version of Next.js direct access to param properties is still supported to facilitate migration but in a future version you will be required to unwrap params with React.use().Answered by B33fb0n3
you can read on how to implement react.use here: https://react.dev/reference/react/use
There are also some example about that. Keep in mind, that
There are also some example about that. Keep in mind, that
params is the promise and not params.id5 Replies
Asian black bear
You can just
await the params object of the page in the server-side code if you use it there. Alternatively just pass the params object to a client component and use(params) it.@Bohemian Waxwing Where can I read how to implement this?
A param property was accessed directly with `params.id`. `params` is now a Promise and should be unwrapped with `React.use()` before accessing properties of the underlying params object. In this version of Next.js direct access to param properties is still supported to facilitate migration but in a future version you will be required to unwrap `params` with `React.use()`.
you can read on how to implement react.use here: https://react.dev/reference/react/use
There are also some example about that. Keep in mind, that
There are also some example about that. Keep in mind, that
params is the promise and not params.idAnswer
@Asian black bear You can just `await` the params object of the page in the server-side code if you use it there. Alternatively just pass the params object to a client component and `use(params)` it.
Bohemian WaxwingOP
I'm using 'use client'. So I can't use await.
@Bohemian Waxwing I'm using 'use client'. So I can't use await.
Asian black bear
There is no reason why a page component should be beneath a client boundary. You should look into it further at some point.