Is this a valid use case for derived state from props? [react]

React documentation seems to be very insistent on the idea that in almost every situation, deriving state from props is a bad idea, an anti-pattern, verbose, likely to cause bugs, hard to understand, and all-around probably going to place a curse on one’s lineage for a thousand years.

My use case isn’t that weird, so I’m probably doing something wrong, but the suggested patterns for not needing getDerivedStateFromProps() (i.e. making Your object fully controlled or fully uncontrolled) don’t seem like good solutions.

The situation: I have a Table component, that takes in an array rows as a prop. Table is used in many different places in my app. I want the Table to be able to handle row-sorting. It is obviously a bad idea to to make whichever parent component controls Table to have to control the sorting*, so fully controlled is out. Making Table fully uncontrolled with a key, also seems like it doesn’t make a lot of sense unless the key is the row-data itself– but my understanding is that key is meant to be simple data (like an id), and actually having to compare all of the rows, which are typically fairly complicated objects, would be pretty inefficient.

My current solution: Table has a state variable sortedRows which is updated either whenever sort() is called or whenever props.rows is updated (via getDerivedStateFromProps), by:

  1. Making a shallow copy of props.rows,
  2. in-place sorting that copy and
  3. updating state.sortedRows on that value.

As I see it, there is still only one source of truth here (which is from props), and the state is always just storing a sorted version of that truth (but always dependent on and in sync with it).

Is this solution bad? If so why? What would be a better way to implement this?

Thanks!

Note: I didn’t include my code because I am massively simplifying the situation in this prompt– in reality Table element already exists, and is pretty complicated.

Note 2: I going to ask if I’d run into issues once I want to be able to modify elements in the tables, but I think I’m actually ok, since Table doesn’t manage its elements, just arrange and display them, and the buttons for adding and removing elements from a table are not contained within Table, so all that processing is happening at the level of the parent’s logic as passed down as part of props.rows

*Having something like <Table rows={sort(rowsFromParent)}/>every time I call Table is repetitive and error-prone, and since clicking on a table header determines sorting column, we’d actually have to have the parent element passing down an onClick() function in every case, which quickly and unnecessarily ramps up complexity).