Quantcast
Channel: ReScript Forum - Latest posts
Viewing all articles
Browse latest Browse all 1856

@obj deprecated how to deal with variadic polymorphic values

$
0
0

I guess you could do something like this:

@unboxed
type rec column<'tableData> =
  | Column({
      id: string,
      accessorFn: 'tableData => 'columnData,
      header?: unit => React.element,
      footer?: unit => React.element,
      cell?: cell<'columnData> => React.element,
    }): column<'tableData>

Usage would be:

useReactTable({
  data,
  columns: [
    Column({
      id:"age",
      accessorFn:test => test.age,
      cell: cell => {
          <p> {cell.getValue()->React.int} </p>
        },
    }),
    Column({id:"firstName", accessorFn:test => test.firstName}),
  ],
  getCoreRowModel: getCoreRowModel(),
})->Js.log

But I agree with you, you could arguably defend that @obj still has some valid use cases.


Viewing all articles
Browse latest Browse all 1856

Trending Articles