question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

A few notes about `useExpanded`

See original GitHub issue

I think there are some use cases the useExpanded could really help with, but there are a few things missing from it that I’d like to talk about:

  1. A way to invert the logic: to show all the subrows by default, and use expanded: false option to hide what is not needed (basically, a default for the undefined expanded). The state.expanded thought then could probably have either a collapsed counterpart or renamed in a way it could be used for both cases? Right now implementing this manually based on what we have can be quite hard.

  2. It would be nice to have an option to count only the non-expanded rows for the pagination, I think right now the pagination takes the subrows into consideration, which sometimes can be not a good thing.

  3. A use-case that I’d really like to see: a way to use not the subRows for an expanded state, but a subComponent or something like that, basically, a single cell with a colSpan equal to the length of the currently visible columns. This is a thing we have used in v6 and I think useExpanded could potentially help use with this.

Actually, a possible interesting implementation of the 3 could be separating existing columns into two arrays: one that is displayed before expand, another — after. This would allow not only to add “multiple columns in always visible part, one big cell after”, but also an inverted “one big cell — header/summary before expanding, multiple columns after”, or even just different various columns, with positioning handled by colSpan, or even with a rowSpan, for columns that would span both initial row and the expanded one!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
tannerlinsleycommented, Dec 12, 2019
  1. Interestingly enough, this is similar to our other discussion about initial state. If expanded: true to have all rows expanded, does the user expect all of the rowIDs to show up in the expanded state immediately?

  2. This already exists. I believe it’s called paginateExpandedRows. Is that what you’re referring to?

  3. This already exists too. You can use the expanded state on rows that are neither grouped or have subRows to do this: https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/sub-components. Is that what you’re referring to?

1reaction
ngouecommented, Dec 18, 2020

Oh hallelujah! I’ve been trying to figure out how I might expand to a custom component for a while now.

https://getyarn.io/yarn-clip/96cb92b6-8ee9-4b64-97e5-e7113a4e2eb4

Read more comments on GitHub >

github_iconTop Results From Across the Web

A few notes about `useExpanded` · Issue #1771 · TanStack/table
A way to invert the logic: to show all the subrows by default, and use expanded: false option to hide what is not...
Read more >
API Reference: useExpanded | React Table - TanStack
useExpanded is the hook that implements row expanding. It is most often used with useGroupBy to expand grouped rows or on its own...
Read more >
Use expanded in a sentence
How to use expanded in a sentence. Example sentences with the word expanded. The most voted sentence example for expanded is Over the...
Read more >
Expanded Form: Why This Math Skill Deserves Classroom ...
Expanded form doesn't get enough love in the classroom. Here's why this skill is so important and how we can reinforce it.
Read more >
4th Grade Math 2.6, Multiply Using Expanded Form - YouTube
Expanded form is a way to write numbers by showing the value of each digit. We can use expanded form to multiply a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found