Skip to content
Permalink
Browse files

fix(use-pagination): fixed use pagination pageIndex bug

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 d50ec588bceb74f7bbf4ab547609a8e312931207
@@ -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 +1,2 @@
import '@testing-library/jest-dom/extend-expect'
import 'snapshot-diff/extend-expect'
@@ -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'

@@ -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,
@@ -60,6 +62,7 @@ function Table({ columns, data }) {
{
columns,
data,
state: tableState,
},
usePagination
)
@@ -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",
@@ -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",
@@ -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",
@@ -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'

0 comments on commit d50ec58

Please sign in to comment.
You can’t perform that action at this time.