Skip to content

Commit 2806dac

Browse files
committed
[IndexTable] Remove useLayoutEffect warning in SSR for IndexTable
1 parent 365e5c8 commit 2806dac

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

.changeset/proud-ways-melt.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/polaris': patch
3+
---
4+
5+
Remove useLayoutEffect warning in SSR for IndexTable.

polaris-react/src/components/IndexTable/IndexTable.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
1-
import React, {
2-
useRef,
3-
useState,
4-
useEffect,
5-
useCallback,
6-
useMemo,
7-
// eslint-disable-next-line no-restricted-imports -- useIsomorphicLayoutEffect is not required for this specific usecase, because we're using useLayoutEffect only for dom manipulation. It has no purpose in server side rendered code.
8-
useLayoutEffect,
9-
} from 'react';
1+
import React, {useRef, useState, useEffect, useCallback, useMemo} from 'react';
102
import {SortAscendingIcon, SortDescendingIcon} from '@shopify/polaris-icons';
113
import type {SpaceScale} from '@shopify/polaris-tokens';
124

135
import {debounce} from '../../utilities/debounce';
146
import {useToggle} from '../../utilities/use-toggle';
7+
import {useIsomorphicLayoutEffect} from '../../utilities/use-isomorphic-layout-effect';
158
import {useI18n} from '../../utilities/i18n';
169
import {Badge} from '../Badge';
1710
import {Checkbox as PolarisCheckbox} from '../Checkbox';
@@ -427,7 +420,7 @@ function IndexTableBase({
427420
scrollingContainer.current = false;
428421
}, []);
429422

430-
useLayoutEffect(() => {
423+
useIsomorphicLayoutEffect(() => {
431424
tableHeadings.current = getTableHeadingsBySelector(
432425
tableElement.current,
433426
'[data-index-table-heading]',

0 commit comments

Comments
 (0)