const React-Table getGroupedRowModel() ์ค๋ฅ = ( Param ) => {
๐ป return Result;
// useReactTable Hook ์ ์ธ
const table = useReactTable({
...
getGroupedRowModel: getGroupedRowModel(),
// getGroupedRowModel๊ฐ ๋ง์ง๋ง์ผ๋ก setPagination์ ํธ์ถํ๊ธฐ ๋๋ฌธ์ ์ฝ์์ฐฝ์ ์ค๋ฅ๊ฐ ๋ฐ์ํจ
// ๋ฐ๋ผ์ ์๋์ ๊ฐ์ด setPagination์ ํธ์ถํ์ง ์๋๋ก ํ๋ฉด ์ค๋ฅ๊ฐ ์ฌ๋ผ์ง
onPaginationChange: () => undefined,
...
});
์ถ์ฒ: https://github.com/TanStack/table/issues/5026#issuecomment-1704318269
Can't perform a React state update on a component that hasn't mounted yet ยท Issue #5026 ยท TanStack/table
Describe the bug Error received when navigating to a table using getGroupedRowModel() such as: const table = useReactTable({ data, columns, getCoreRowModel: getCoreRowModel(), getGroupedRowModel: g...
github.com
๐ console.log( history )

์ต๊ทผ ํผ์ ํ ์ด ํ๋ก์ ํธ๋ฅผ ์งํํ๋ฉด์ ํ ์ด๋ธ ๊ธฐ๋ฅ์ด ํ์ํ๋ค. ์ปดํฌ๋ํธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ React๋ฅผ ์์ํ ๋๋ถํฐ ๊พธ์คํ ์จ์๊ธฐ ๋๋ฌธ์ ํ๋ณด์์ ์ ์ธํ๋ค. ์ฌ์ด๋ ํ๋ก์ ํธ ์งํํ๋ฉด์ Headless ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ๋ํ ์ ๋ณด๋ฅผ ๋ค์ด ์ด๋ฒ ํ ์ด ํ๋ก์ ํธ๋ฅผ ์งํํ๋ฉด์ ์จ๋ณด๊ธฐ๋ก ํ๋ค.
์๊ฐ๋ณด๋ค ๋ง์ Headless ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ค์ด ์กด์ฌํ๊ณ ๊ทธ์ค์์ React-Query๋ก ์ต์ํ TanStack์ React-Table์ ์ฌ์ฉํ๊ธฐ๋ก ํ๋ค. Headless ๊ธฐ๋ฅ์ ์ฒ์ ์จ๋ณด๋ค ๋ณด๋ ๋ง์ด ํค๋งค๊ธด ํ์ง๋ง ๊ณต์ ๋ฌธ์์ ํ์ ๋น๋ ค ํ์ํ ๊ธฐ๋ฅ๊น์ง ๊ตฌํํ๋ค.
ํ ์ด๋ธ์์ Type์ ๊ธฐ์ค์ผ๋ก Grouping์ ํ์ฌ ํํํ๊ณ ์ถ์ด getGroupedRowModel()๋ฅผ ํตํด์ ๊ทธ๋ฃน ๋ฐ์ดํฐ๋ฅผ ๋ฐ์์ ํ ์ด๋ธ์ ๊ตฌ์ฑํ๋๋ฐ ์ฝ์์ฐฝ์ ์ค๋ฅ๊ฐ ๋ฐ์ํ๋ค. ๋จ์ํ React-Table์ ํจ์๋ฅผ ๋ฐ์ ์ ๊ณตํ ๊ฒ ๋ฐ์ ์์ด์ ๋นํฉ์ค๋ฌ์ด ์ค๋ฅ์๋ค.
์์ฑํ ์ฝ๋ ์ค์๋ ๋ฌธ์ ๊ฐ ์๋ค๊ณ ํ๋จํ๊ณ ๊ตฌ๊ธ์ ์ด์ฌํ ๊ฒ์ํ ๊ฒฐ๊ณผ ๋์ ๊ฐ์ ์ค๋ฅ๋ฅผ ๊ฒช์ ๊ฐ๋ฐ์๊ฐ Issue๋ฅผ ์ฌ๋ ธ๊ณ ํด๋น Issue ๊ฒ์๊ธ ๋ต๋ณ์ ํด๊ฒฐ๋ฐฉ์์ด ์์๋ค.
getGroupedRowModel ํจ์๊ฐ setPagination์ ๋ง์ง๋ง์ผ๋ก ํธ์ถํ์ฌ ๋ฐ์ํ๋ ๊ฒ์ด์๋ค. Paging ๊ธฐ๋ฅ์ ์ฌ์ฉํ์ง ์์๋ฐ ๋ฐ์ํ๋ ๊ฒ์ ์์ํ์ง๋ง ํจ์๊ฐ setPagination์ ํธ์ถํ๊ธฐ ๋๋ฌธ์ onPaginationChange ์ด๋ฒคํธ ํจ์๋ฅผ ์ง์ ํ์ฌ ํด๊ฒฐ์ด ๊ฐ๋ฅํ๋ค.
/ / Improvements
ํด๋น Issue ๊ฒ์๊ธ์ ๋ณด์์ ๋ getGroupedRowModel ๋ฟ๋ง ์๋๋ผ getFacetedUniqueValues์ ๊ฐ์ ๋ค๋ฅธ ํจ์์์๋ ๋ฐ์ํ๋ค.
๋น๋ํ์ฌ ํ ์คํธํ์ ๋ ํด๋น ์ค๋ฅ๋ ๋ฐ์ํ์ง ์๋๋ค. dev ๋ชจ๋์ผ ๋ React Strict Mode์ ์ํด์ ๋ฐ์ํ๋ ์ค๋ฅ๋ก ๋ณด์ธ๋ค.
}
'DEV > WebProgramming' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[React.js] ๋น๋ ํ ํ๊ฒฝ๋ณ์ ์์ (0) | 2024.07.12 |
---|---|
[React.js] debounce ์ฌ์ฉํ๊ธฐ (0) | 2024.07.09 |
[JavaScript] ์ฌ์ฉ์ ์คํฌ๋กค ๋ง๊ธฐ ๋ฐ ์คํฌ๋กค ์ฌ๋ฐฑ ์ฒ๋ฆฌ (0) | 2024.04.20 |
[React.js] ์์ ๋ก๊ทธ์ธ ๊ตฌํ - ์นด์นด์ค (0) | 2023.04.28 |
[React.js] Viewport์ ๋์ ์ผ๋ก meta ํ๊ทธ ์์ ํ๊ธฐ (0) | 2023.01.31 |