RowLabelArgs index type became optional since 1.8.3?

default discord avatar
derosul
4 months ago
6

Since the 1.8.3 update, al of my RowLabel functions are being errored by Typescript. This is because the index key seems to be optional.



When pasting the example as found in the Payload documentation, it gives an error.




 admin: {
        components: {
          RowLabel: ({ data, index }) => {
            return data?.title || `Slide ${String(index).padStart(2, '0')}`;
          },
        },
      },


Weird... git blame shows the type definition for

index

has been optional for 6 months already... Wonder why it shows up now. It even fails my build...

  • discord user avatar
    jmikrut
    Payload Team
    4 months ago

    blame typescript updates

  • default discord avatar
    derosul
    4 months ago

    Managed to fix this by enforcing the type using the exported "RowLabelArgs"



    example:


     RowLabel: ({data, index}: RowLabelArgs) => {
  • default discord avatar
    arctomachine
    4 months ago

    Does it actually work for you? For me it gives different error instead



    It marks not just property name, but whole value too

    image.png
  • discord user avatar
    jarrod_not_jared
    Payload Team
    4 months ago

    @arctomachine it looks like you are trying to use RowLabel on a text field? You should be using it on an array field: i.e.

    https://payloadcms.com/docs/fields/array#example
  • default discord avatar
    arctomachine
    4 months ago

    Oh, right. Was trying to give it to title field instead of whole array 🤣

  • default discord avatar
    nlvogel
    6 days ago

    Sorry to resurrect this help article from the dead, but I was wondering if you got rid of the errors. Your fix helped my at least get my build up, but I still have a sea of red lines in my IDE lol

Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.