Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

RowLabelArgs index type became optional since 1.8.3?

default discord avatar
derosul2 years 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
    2 years ago

    blame typescript updates

  • default discord avatar
    derosul2 years ago

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



    example:


     RowLabel: ({data, index}: RowLabelArgs) => {
  • default discord avatar
    arctomachine2 years ago

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



    It marks not just property name, but whole value too

  • discord user avatar
    jarrod_not_jared
    2 years ago
    @220641138267258892

    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
    arctomachine2 years ago

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

  • default discord avatar
    nlvogellast year

    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

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.