React-table: v7 default sort

Created on 16 Aug 2019  ·  4Comments  ·  Source: tannerlinsley/react-table

Hello,
How to default sort on v7 ?

Most helpful comment

For anyone else that comes looking, here is a working example: https://codesandbox.io/s/tannerlinsleyreact-table-default-sorting-6i6xn

(Note that there is no use of a useTableState plugin; I could not find one, and it doesn't appear to be necessary anyway.)

All 4 comments

useTableState allows you to do this:

const tableState = useTableState({
  sortBy: [{
    id: 'firstName',
    desc: true,
  }]
})

const instance = useTable({
  state: tableState
})

That was fast ! Great thanks

On Fri, Aug 16, 2019 at 5:02 PM Tanner Linsley notifications@github.com
wrote:

useTableState allows you to do this:

const tableState = useTableState({
sortBy: [{
id: 'firstName',
desc: true,
}]
})
const instance = useTable({
state: tableState
})


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/tannerlinsley/react-table/issues/1456?email_source=notifications&email_token=ABPAMXLA53H3FAUR3OCIXDTQE26QFA5CNFSM4IMKB6Y2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4O3N7Q#issuecomment-522041086,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABPAMXMDDIP7ZQ6REJJS6OLQE26QFANCNFSM4IMKB6YQ
.

--
Jean Chapelle

initialState.sortBy = [{id: “firtsName”}]

Tanner Linsley
On Oct 25, 2019, 10:03 AM +0200, Chun-Lin Wu notifications@github.com, wrote:

useTableState allows you to do this:
const tableState = useTableState({
sortBy: [{
id: 'firstName',
desc: true,
}]
})

const instance = useTable({
state: tableState
})
Looks like useTableState is deprecated in newest API. How can I use sortBy function to do default sorting now? Thanks!

You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub, or unsubscribe.

For anyone else that comes looking, here is a working example: https://codesandbox.io/s/tannerlinsleyreact-table-default-sorting-6i6xn

(Note that there is no use of a useTableState plugin; I could not find one, and it doesn't appear to be necessary anyway.)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

danielmariz picture danielmariz  ·  3Comments

mellis481 picture mellis481  ·  3Comments

kieronsutton00 picture kieronsutton00  ·  3Comments

Abdul-Hameed001 picture Abdul-Hameed001  ·  3Comments

alexanderwhatley picture alexanderwhatley  ·  3Comments