- )
-}
-```
+- [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/basic)
+- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/basic)
# `useSortBy`
@@ -503,63 +429,8 @@ The following properties are available on every `Column` object returned by the
### Example
-```js
-function Table({ columns, data }) {
- // Set some default sorting state. For this an additional import of useTableState is needed
- const state = useTableState({ sortBy: [{ id: 'firstName', desc: true }] })
-
- const { getTableProps, headerGroups, rows, prepareRow } = useTable(
- {
- columns,
- data,
- state,
- },
- useSortBy // Use the sortBy hook
- )
-
- return (
-
-
- {headerGroups.map(headerGroup => (
-
- {headerGroup.headers.map(column => (
- // Add the sorting props to control sorting. For this example
- // we can add them into the header props
-
-}
-```
+- [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/expanding)
+- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/expanding)
# `usePagination`
@@ -1199,178 +751,12 @@ The following values are provided to the table `instance`:
### Example
-```js
-function Table({ columns, data }) {
- // Use the state and functions returned from useTable to build your UI
- const {
- getTableProps,
- headerGroups,
- prepareRow,
- page, // Instead of using 'rows', we'll use page,
- // which has only the rows for the active page
-
- // The rest of these things are super handy, too ;)
- canPreviousPage,
- canNextPage,
- pageOptions,
- pageCount,
- gotoPage,
- nextPage,
- previousPage,
- setPageSize,
- state: [{ pageIndex, pageSize }],
- } = useTable(
- {
- columns,
- data,
- },
- usePagination
- )
-
- // Render the UI for your table
- return (
- <>
-
-}
-```
+- [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/row-selection)
+- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/row-selection)
# `useRowState`
@@ -1635,7 +906,7 @@ The following additional properties are available on every `Cell` object returne
### Example
-- [Source + Guide](https://github.com/tannerlinsley/react-table/tree/master/examples/block-layout)
+- [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/block-layout)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/block-layout)
# `useAbsoluteLayout`
@@ -1673,7 +944,7 @@ The following additional properties are available on every `Cell` object returne
### Example
-- [Source + Guide](https://github.com/tannerlinsley/react-table/tree/master/examples/absolute-layout)
+- [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/absolute-layout)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/absolute-layout)
# `useColumnOrder`
@@ -1697,9 +968,13 @@ The following options are supported via the main options object passed to `useTa
The following values are provided to the table `instance`:
- `setColumnOrder: Function(updater: Function | Array) => void`
+
- Use this function to programmatically update the columnOrder.
- `updater` can be a function or value. If a `function` is passed, it will receive the current value and expect a new one to be returned.
+- [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/column-ordering)
+- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/column-ordering)
+
# `useTableState`
- Optional
@@ -1758,26 +1033,6 @@ The following options are supported via the main options object passed to `useTa
### Example
-```js
-export default function MyTable({ manualPageIndex }) {
- // This is the initial state for our table
- const initialState = { pageSize: 10, pageIndex: 0 }
-
- // Here, we can override the pageIndex
- // regardless of the internal table state
- const overrides = React.useMemo(() => ({
- pageIndex: manualPageIndex,
- }))
-
- const state = useTableState(initialState, overrides)
-
- // You can use effects to observe changes to the state
- React.useEffect(() => {
- console.log('Page Size Changed!', initialState.pageSize)
- }, [initialState.pageSize])
-
- const { rows } = useTable({
- state,
- })
-}
-```
+- As used in Controlled Pagination
+ - [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/pagination-controlled)
+ - [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/pagination-controlled)
diff --git a/docs/examples.md b/docs/examples.md
index 99154fb..68a9795 100644
--- a/docs/examples.md
+++ b/docs/examples.md
@@ -2,52 +2,52 @@
- **Simple** - All of these examples use automatic state management, meaning, they don't hoist any state out of the table or manually control anything. Start here for understanding the basics about how to build your table UI.
- Basic
- - [Source + Guide](https://github.com/tannerlinsley/react-table/tree/master/examples/basic)
+ - [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/basic)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/basic)
- Sorting
- - [Source + Guide](https://github.com/tannerlinsley/react-table/tree/master/examples/sorting)
+ - [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/sorting)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/sorting)
- Filtering
- - [Source + Guide](https://github.com/tannerlinsley/react-table/tree/master/examples/filtering)
+ - [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/filtering)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/filtering)
- Grouping
- - [Source + Guide](https://github.com/tannerlinsley/react-table/tree/master/examples/grouping)
+ - [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/grouping)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/grouping)
- Pagination
- - [Source + Guide](https://github.com/tannerlinsley/react-table/tree/master/examples/pagination)
+ - [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/pagination)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/pagination)
- Row Selection
- - [Source + Guide](https://github.com/tannerlinsley/react-table/tree/master/examples/row-selection)
+ - [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/row-selection)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/row-selection)
- Expanding
- - [Source + Guide](https://github.com/tannerlinsley/react-table/tree/master/examples/expanding)
+ - [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/expanding)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/expanding)
- Sub Components
- - [Source + Guide](https://github.com/tannerlinsley/react-table/tree/master/examples/sub-components)
+ - [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/sub-components)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/sub-components)
- Editable Data
- - [Source + Guide](https://github.com/tannerlinsley/react-table/tree/master/examples/editable-data)
+ - [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/editable-data)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/editable-data)
- Column Ordering
- - [Source + Guide](https://github.com/tannerlinsley/react-table/tree/master/examples/column-ordering)
+ - [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/column-ordering)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/column-ordering)
- **Complex**
- The "Kitchen Sink"
- - [Source + Guide](https://github.com/tannerlinsley/react-table/tree/master/examples/kitchen-sink)
+ - [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/kitchen-sink)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/kitchen-sink)
- **Controlled via `useTableState`** - These examples are more advanced because they demonstrate how to manually control and respond to the state of the table using the `useTableState` hook.
- Pagination (Controlled)
- - [Source + Guide](https://github.com/tannerlinsley/react-table/tree/master/examples/pagination-controlled)
+ - [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/pagination-controlled)
- [Open in CodeSandobx](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/pagination-controlled)
- **UI & Rendering** - These examples demonstrate how to use React Table with your favorite UI libraries or tools!
- Virtualized Rows (React-Window)
- - [Source + Guide](https://github.com/tannerlinsley/react-table/tree/master/examples/virtualized-rows)
+ - [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/virtualized-rows)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/virtualized-rows)
- Animated (Framer-Motion)
- - [Source + Guide](https://github.com/tannerlinsley/react-table/tree/master/examples/animated-framer-motion)
+ - [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/animated-framer-motion)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/animated-framer-motion)
- Material-UI
- - [Source + Guide](https://github.com/tannerlinsley/react-table/tree/master/examples/material-UI-components)
+ - [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/material-UI-components)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/material-UI-components)
- [ ] Styled-Components
- [ ] CSS