Skip to content

Commit

Permalink
fix(use-pagination): fixed use pagination pageIndex bug
Browse files Browse the repository at this point in the history
Use pagination will no longer synchronously reset the pageIndex to 0 on mount
  • Loading branch information
tannerlinsley committed Aug 15, 2019
1 parent f9242f6 commit d50ec58
Show file tree
Hide file tree
Showing 20 changed files with 699 additions and 681 deletions.
1 change: 1 addition & 0 deletions configs/tests/jest.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ module.exports = {
rootDir: path.resolve(__dirname, '../../'),
roots: ['<rootDir>/src', __dirname],
transformIgnorePatterns: ['node_modules'],
snapshotSerializers: [require.resolve('snapshot-diff/serializer.js')],
}
1 change: 1 addition & 0 deletions configs/tests/setup.common.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
import '@testing-library/jest-dom/extend-expect'
import 'snapshot-diff/extend-expect'
5 changes: 4 additions & 1 deletion examples/pagination/src/App.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import styled from 'styled-components'
import { useTable, usePagination } from 'react-table'
import { useTable, usePagination, useTableState } from 'react-table'

import makeData from './makeData'

Expand Down Expand Up @@ -38,6 +38,8 @@ const Styles = styled.div`
`

function Table({ columns, data }) {
const tableState = useTableState({ pageIndex: 2 })

// Use the state and functions returned from useTable to build your UI
const {
getTableProps,
Expand All @@ -60,6 +62,7 @@ function Table({ columns, data }) {
{
columns,
data,
state: tableState,
},
usePagination
)
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@
"@commitlint/cli": "^8.1.0",
"@commitlint/config-conventional": "^8.1.0",
"@svgr/rollup": "^4.3.2",
"@testing-library/dom": "^5.6.0",
"@testing-library/dom": "^6.0.0",
"@testing-library/jest-dom": "^4.0.0",
"@testing-library/react": "^8.0.7",
"@testing-library/react": "^9.1.1",
"babel-eslint": "9.x",
"commitizen": "^4.0.3",
"core-js": "3",
"core-js": "3.2.1",
"cross-env": "^5.2.0",
"eslint": "5.x",
"eslint-config-prettier": "^4.3.0",
Expand All @@ -70,9 +70,9 @@
"eslint-plugin-prettier": "^3.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-react": "7.14.3",
"eslint-plugin-react-hooks": "1.6.1",
"eslint-plugin-react-hooks": "1.7.0",
"eslint-plugin-standard": "^4.0.0",
"husky": "^3.0.2",
"husky": "^3.0.3",
"is-ci-cli": "^1.1.1",
"jest": "^24.8.0",
"jest-cli": "^24.8.0",
Expand All @@ -81,8 +81,8 @@
"jest-watch-typeahead": "^0.3.1",
"lint-staged": "^9.2.1",
"prop-types": "^15.5.0",
"react": "^16.8.3",
"react-dom": "^16.8.3",
"react": "^16.9.0",
"react-dom": "^16.9.0",
"rollup": "^0.68.0",
"rollup-plugin-babel": "^4.3.3",
"rollup-plugin-commonjs": "^9.1.3",
Expand Down
3 changes: 0 additions & 3 deletions src/hooks/tests/useTable.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import '@testing-library/react/cleanup-after-each'
import '@testing-library/jest-dom/extend-expect'

import React from 'react'
import { render } from '@testing-library/react'
import { useTable } from '../useTable'
Expand Down
Loading

0 comments on commit d50ec58

Please sign in to comment.