menu
techminis

A naukri.com initiative

google-web-stories
Home

>

Programming News

>

Advanced typings
source image

Dev

2w

read

78

img
dot

Image Credit: Dev

Advanced typings

  • To declare the type of another component's prop to accept only the keys of the data type returned by the data-fetching function, you can use `keyof`.
  • By defining the component's type with `keyof`, the type of the `key` prop becomes the union of keys of the awaited response of the function.
  • If the function returns an array, you can use the `KeyOf` helper to infer the key type from the returned array.
  • Both server-side and client-side component examples are provided for implementing the type declaration.

Read Full Article

like

4 Likes

For uninterrupted reading, download the app