Skip to content
Discussion options

You must be logged in to vote

You can keep v9's atom ownership and still use onSortingChange to enforce the extra sort. atoms.sorting supplies the current value, so you don't need state.sorting or a React state setter.

For the pins-enabled case, keeping your existing features, columns and data setup,

import { useCreateAtom } from '@tanstack/react-store'
import { functionalUpdate, type SortingState } from '@tanstack/react-table'

const sortingAtom = useCreateAtom<SortingState>([
  { id: 'isPinned', desc: true },
])

const table = useTable({
  features,
  columns,
  data,
  atoms: { sorting: sortingAtom },
  onSortingChange: (updater) => {
    sortingAtom.set((old) => [
      { id: 'isPinned', desc: true },
      ...fun…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@phb-ig
Comment options

Answer selected by phb-ig
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
2 participants