Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug ]: Tabs component is not rendering correctly in Remix.run (SSR) #13702

Open
2 tasks done
bouraine opened this issue May 2, 2023 · 2 comments
Open
2 tasks done

[Bug ]: Tabs component is not rendering correctly in Remix.run (SSR) #13702

bouraine opened this issue May 2, 2023 · 2 comments

Comments

@bouraine
Copy link

bouraine commented May 2, 2023

Package

@carbon/react

Browser

Chrome

Package version

112.0.5615.138 (Official Build) (64-bit)

React version

18.2.0

Description

I have this error when i try to add Tabs component to remix.run page Uncaught Error: Hydration failed because the initial UI does not match what was rendered on the server.

Here is how the tabs are rendered:

image

Tested example:

<Tabs>
  <TabList aria-label="List of tabs">
    <Tab>Tab label 1</Tab>
    <Tab>Tab label 2</Tab>
  </TabList>
  <TabPanels>
   <TabPanel>Tab Panel 1</TabPanel>
   <TabPanel>Tab Panel 2</TabPanel>
  </TabPanels>
</Tabs>

``

The problem is caused by @carbon/feature-flags module which returns different results in client and the server.

This line returns false the first time it is executed on client (web) even if the flag enable-v11-release is enabled.

workaround

A workarround i found for now is to fork the @carbon/feature-flags package, fix the bug and and reference my local fork in package.json

image

image

Reproduction/example

https://stackblitz.com/edit/remix-carbon-dmnxpk?file=app/entry.server.tsx

Steps to reproduce

https://stackblitz.com/edit/remix-carbon-dmnxpk?file=app/entry.server.tsx

Suggested Severity

Severity 3 = User can complete task, and/or has a workaround within the user experience of a given component.

Application/PAL

No response

Code of Conduct

@bouraine bouraine changed the title [Bug]: Error while rendering Carbon 11 Tabs component in Remix.run project: Hydration failed because the initial UI does not match what was rendered on the server. [Bug ]: Tabs component is not rendering correctly in Remix.run May 2, 2023
@bouraine bouraine changed the title [Bug ]: Tabs component is not rendering correctly in Remix.run [Bug ]: Tabs component is not rendering correctly in Remix.run (SSR) May 2, 2023
@tay1orjones
Copy link
Member

@bouraine thanks for reporting, I think this will be solved by #13727 which should turn on the feature flag by default.

In this case it's convenient that this flag can be set to true, but for other flags that may not be the case and this same issue could crop up again. I assume it's because the flags are initialized to one value initially in @carbon/feature-flags

- name: enable-v11-release
description: >
Enable the features and functionality for the v11 Release
enabled: true

and then set client-side here

import './feature-flags';

import * as FeatureFlags from '@carbon/feature-flags';
FeatureFlags.merge({
'enable-css-custom-properties': true,
'enable-css-grid': true,
'enable-v11-release': true,
'enable-experimental-tile-contrast': false,
});

We'll need to look into how to fix this.

@tay1orjones
Copy link
Member

Related #13505

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: ⏱ Backlog
Development

No branches or pull requests

2 participants