Skip to content

Commit

Permalink
[IndexTable] Remove useLayoutEffect warning in SSR for IndexTable
Browse files Browse the repository at this point in the history
  • Loading branch information
jesstelford committed May 13, 2024
1 parent 365e5c8 commit 2806dac
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/proud-ways-melt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/polaris': patch
---

Remove useLayoutEffect warning in SSR for IndexTable.
13 changes: 3 additions & 10 deletions polaris-react/src/components/IndexTable/IndexTable.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import React, {
useRef,
useState,
useEffect,
useCallback,
useMemo,
// 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.
useLayoutEffect,
} from 'react';
import React, {useRef, useState, useEffect, useCallback, useMemo} from 'react';
import {SortAscendingIcon, SortDescendingIcon} from '@shopify/polaris-icons';
import type {SpaceScale} from '@shopify/polaris-tokens';

import {debounce} from '../../utilities/debounce';
import {useToggle} from '../../utilities/use-toggle';
import {useIsomorphicLayoutEffect} from '../../utilities/use-isomorphic-layout-effect';
import {useI18n} from '../../utilities/i18n';
import {Badge} from '../Badge';
import {Checkbox as PolarisCheckbox} from '../Checkbox';
Expand Down Expand Up @@ -427,7 +420,7 @@ function IndexTableBase({
scrollingContainer.current = false;
}, []);

useLayoutEffect(() => {
useIsomorphicLayoutEffect(() => {
tableHeadings.current = getTableHeadingsBySelector(
tableElement.current,
'[data-index-table-heading]',
Expand Down

0 comments on commit 2806dac

Please sign in to comment.