TypeScript Usage
TanStack Table itself is written in TypeScript, and Mantine React Table builds on top of its great type definitions for best in class TypeScript experience.
If, however, you cannot use TypeScript in your project for some reason, checkout down below for how to use JSDoc instead of TypeScript to get the same type hints.
Is TypeScript Required?
No, TypeScript is not required to use Mantine React Table. You can just use JavaScript and everything will work just fine, but you will be missing out on a lot of great type hints and type safety that can help you build your app faster and with less bugs.
Define You TData Type
Mantine React Table makes use of generics to make working with your specific row data structures easier. You will see that most of the
MRT_*
types that you can use accept a TData
generic.Let's say that the data in your table is an array of users that looks like this:
Then your
TData
type can be defined as:Define Your Column Definitions with MRT_ColumnDef
Mantine React Table provides you with a
MRT_ColumnDef
type that you can use to define your column definitions. It is a generic type that accepts your TData
type as a generic.Use JSDoc instead of TypeScript
If you are in a situation where you are not able to install TypeScript in your project, you can technically do the same thing as up above in JavaScript using JSDoc.