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...
blame typescript updates
Managed to fix this by enforcing the type using the exported "RowLabelArgs"
example:
RowLabel: ({data, index}: RowLabelArgs) => {
Does it actually work for you? For me it gives different error instead
It marks not just property name, but whole value too
@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#exampleOh, right. Was trying to give it to title field instead of whole array 🤣
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
Discord
online
Get help straight from the Payload team with an Enterprise License.