Search code examples
reactjsdatatable

REACT DataTable error - Parameter 'row' implicity has an 'any' type


I am seeing the TypeScript error 'Parameter 'row' implicitly has an 'any' type' in my React datatable component, which occur when I declare this code in column selector, value row is highlighted with red.

Parameter 'row' implicitly has an 'any' type.
     8 |         {
     9 |             name: 'Year',
  > 10 |             selector: row => row.year,
       |                       ^^^
    11 |         },
    12 |     ];

This is the code

const columns = [
        {
            name: 'Title',
            selector: row => row.title,
        },
        {
            name: 'Year',
            selector: row => row.year,
        },
    ]; 

I am a newbie in react. Any help will be appreciated :)


Solution

  • After searching about implicity has an 'any' type I got the answer and this is the example code.

    const columns = [
        {
            name: 'Title',
            selector: (row:any) => row.title
        },
        {
            name: 'Year',
            selector: (row:any) => row.year
        },
    ];
    

    That's it, just put row inside parenthesis and add value of any. :)