From 2a20ad3ba42318a8cfa881dd37016985db037d80 Mon Sep 17 00:00:00 2001 From: tannerlinsley Date: Thu, 18 Jul 2019 15:06:10 -0600 Subject: [PATCH] Update App.js --- examples/basic/src/App.js | 82 +++++++++++++++++++-------------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/examples/basic/src/App.js b/examples/basic/src/App.js index 97e136c..4f652e3 100644 --- a/examples/basic/src/App.js +++ b/examples/basic/src/App.js @@ -33,9 +33,46 @@ const Styles = styled.div` } ` -const data = makeData(20) +function Table({ columns, data }) { + // Use the state and functions returned from useTable to build your UI + const { getTableProps, headerGroups, rows, prepareRow } = useTable( + { + columns, + data, + }, + useColumns, + useRows + ) -function Table() { + // Render the UI for your table + return ( + + + {headerGroups.map(headerGroup => ( + + {headerGroup.headers.map(column => ( + + ))} + + ))} + + + {rows.map( + (row, i) => + prepareRow(row) || ( + + {row.cells.map(cell => { + return + })} + + ) + )} + +
{column.render('Header')}
{cell.render('Cell')}
+ ) +} + +function App() { const columns = React.useMemo( () => [ { @@ -76,48 +113,11 @@ function Table() { [] ) - // Use the state and functions returned from useTable to build your UI - const { getTableProps, headerGroups, rows, prepareRow } = useTable( - { - columns, - data, - }, - useColumns, - useRows - ) + const data = React.useMemo(() => makeData(20), []) - // Render the UI for your table - return ( - - - {headerGroups.map(headerGroup => ( - - {headerGroup.headers.map(column => ( - - ))} - - ))} - - - {rows.map( - (row, i) => - prepareRow(row) || ( - - {row.cells.map(cell => { - return - })} - - ) - )} - -
{column.render('Header')}
{cell.render('Cell')}
- ) -} - -function App() { return ( - +
) }