Where can I find documentation for writing custom plugins and hooks?
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.
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.