React-table: Custom hooks & plugins

Created on 25 May 2020  路  2Comments  路  Source: tannerlinsley/react-table

Where can I find documentation for writing custom plugins and hooks?

Most helpful comment

I'm putting off a plugin guide until v8 where it will be a much better experience and make way more sense.

All 2 comments

Where can I find documentation for writing custom plugins and hooks?

I have built custom hooks by reading any of their plugin hooks implementation, in this way:

Take a look at any of the plugin hooks written for example usePagination etc..

React-table exposes all required plugin points (instance.hooks)

To get these plugin points, we pass our useCustomHook to useTable just like how we pass usePagination, useGroupby to useTable

In useCustomHook, select any of the plugin points (or push to an array) you want to add logic

function useInstanceFn(instance) {
  console.log(instance)
   // Implement logic
}

export function useCustomHook(hooks) {
    // plugin points (hooks)
    hooks.useInstance.push(useInstanceFn)
}

useCustomHook gets table instance, table instance has everything you need to build your own logic. You can also return new state using instance.dispatch and reducer

Edit link: https://github.com/tannerlinsley/react-table/tree/master/docs/api#the-stages-of-react-table-and-plugins

I'm putting off a plugin guide until v8 where it will be a much better experience and make way more sense.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bdkersey picture bdkersey  路  3Comments

dilipsundarraj1 picture dilipsundarraj1  路  3Comments

missmellyg85 picture missmellyg85  路  3Comments

tremby picture tremby  路  3Comments

LeonHex picture LeonHex  路  3Comments