Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow extending core table features #399

Merged
merged 1 commit into from
Feb 26, 2023
Merged

Allow extending core table features #399

merged 1 commit into from
Feb 26, 2023

Conversation

hitendramalviya
Copy link
Contributor

@hitendramalviya hitendramalviya commented Feb 25, 2023

Consumer can attach more feature to existing table instance, which was not possible through ref table instance after re-render it is getting initialised again. In this PR, with each re-render it will assign extended features to the created table instance again, which will be available across through ref & props.

e.g.

function advanceSearchFeature<TData extends Record<string, any> = {}>(table: MRT_TableInstance<TData>) {
  return {
    getAdvanceSearchFilters: () => table.getState().advanceFilters;
  }
}

<MaterialReactTable 
  ...
  state={{ advanceFilters }} //manage your own state, pass it back to the table (optional)
/>

// Other place in consumer
const handleAdvanceSearch = () => {
  const filters = tableInstanceRef.current.getAdvanceSearchFilters();
  ...
};

@vercel
Copy link

vercel bot commented Feb 25, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
material-react-table ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Feb 25, 2023 at 2:07AM (UTC)
material-react-table-storybook ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Feb 25, 2023 at 2:07AM (UTC)

Copy link
Owner

@KevinVandy KevinVandy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm probably not going to document much of this, because its advanced unpredictable usage, but it probably will not affect anything else

@KevinVandy KevinVandy merged commit b3cf4bd into KevinVandy:main Feb 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants