-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow user to show pagination somewhere else
- Loading branch information
1 parent
f6ff8fa
commit 01e768b
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React from 'react'; | ||
import { connect } from 'react-redux'; | ||
import makeSelectors from './selectors'; | ||
import { tablePageChanged } from './actions'; | ||
import Pagination from './Pagination'; | ||
|
||
const mapStateToProps = (state, { tableName }) => { | ||
const selectors = makeSelectors(tableName); | ||
const isInitialized = selectors.getIsInitialized(state); | ||
|
||
if (!isInitialized) { | ||
return { | ||
isInitialized, | ||
}; | ||
} | ||
|
||
const pageInfo = selectors.getPageInfo(state); | ||
|
||
return { | ||
isInitialized, | ||
...pageInfo, | ||
}; | ||
}; | ||
|
||
const mapDispatchToProps = (dispatch, { tableName }) => ({ | ||
onPageChange: (page) => dispatch(tablePageChanged(tableName, page)), | ||
}); | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(({ | ||
isInitialized, | ||
...otherProps | ||
}) => { | ||
if (!isInitialized) { return null; } | ||
return <Pagination {...otherProps} />; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters