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

Banner and FilterControl break React hydration #1283

Closed
GoodForOneFare opened this issue Apr 8, 2019 · 13 comments
Closed

Banner and FilterControl break React hydration #1283

GoodForOneFare opened this issue Apr 8, 2019 · 13 comments
Labels
Bug Something is broken and not working as intended in the system.

Comments

@GoodForOneFare
Copy link
Member

Issue summary

I've had to disable some SSR in an internal Shopify project because a couple of Polaris components don't have consistent IDs between server / client.

Banner's unique ID helper is defined at module scope, and never resets on the server side: https://github.com/Shopify/polaris-react/blob/9aa2768d29d9548ac88728580340bfa42b8b7e1f/src/components/Banner/Banner.tsx#L182-L185

TextField's id factory can be overridden, but FilterControl doesn't give callers control over this: https://github.com/Shopify/polaris-react/blob/9aa2768d29d9548ac88728580340bfa42b8b7e1f/src/components/ResourceList/components/FilterControl/FilterControl.tsx#L95-L110

Expected behavior

  • Banner should accept an id prop
  • ResourceList should either accept an id prop and pass it on to FilterControl -> TextArea (or make everything magically work 😄)

Actual behavior

Banners and ResourcesLists rendered server side hydrate properly on the first load after server startup. Then fail to hydrate on every other page load.

Steps to reproduce the problem

Message me, and I'll describe how to get an internal project into this state.

Reduced test case

N/A because this needs a server.

Specifications

  • Are you using the React components? (Y/N): Y
  • Polaris version number: 3.12.0
  • Browser: all
  • Device: Macbook Pro
  • Operating System: Mojave 10.14.3
@GoodForOneFare GoodForOneFare added the Bug Something is broken and not working as intended in the system. label Apr 8, 2019
@alex-page
Copy link
Member

alex-page commented Apr 8, 2019

Thanks for bringing this up @GoodForOneFare. I'll have a look in the next day or two.

@alex-page alex-page self-assigned this Apr 8, 2019
@alex-page alex-page removed their assignment Apr 15, 2019
@alex-page
Copy link
Member

We probably just need to remove the ID from Banner as it's not used for any accessibility enhancements.

@GoodForOneFare
Copy link
Member Author

SearchField now uses module-scoped unique ids and now causes SSR warnings in web.

@CameronGorrie
Copy link
Contributor

Screen Shot 2019-06-28 at 12 06 27 PM

@ghost
Copy link

ghost commented Dec 25, 2019

This issue has been inactive for 180 days and labeled with Icebox. It will be closed in 7 days if there is no further activity.

@ghost ghost added the Icebox label Dec 25, 2019
@ghost ghost closed this as completed Jan 1, 2020
@BPScott
Copy link
Member

BPScott commented Jan 4, 2020

Reopening this as SSR discrepancies are still an issue

@BPScott BPScott reopened this Jan 4, 2020
@BPScott
Copy link
Member

BPScott commented Jan 4, 2020

ping @yourpalsonja, it'd be good for the backlog buddies to take a look at this and #1046

@ghost ghost closed this as completed Jan 11, 2020
@chrisandrewca
Copy link

Hi, I'm seeing a similar issue with ResourceList. The 'Showing x items' title is missing. The promoted action is also missing when configured.

Warning: Prop id did not match. Server: "ResourceListItemOverlay11" Client: "ResourceListItemOverlay1"

1

Are you using the React components? (Y/N): Y
Polaris version number: 4.9.0
Browser: chrome
Device: desktop
Operating System: windows

Server side rendering: Y
Next.js

When I disable SSR for this scenario, the console error disappears but the title and buttons remain missing.

@BPScott
Copy link
Member

BPScott commented Jan 11, 2020

Probot. Stop that.

@BPScott BPScott reopened this Jan 11, 2020
@BPScott BPScott removed the Icebox label Jan 11, 2020
@KyleKilbride
Copy link

Hey 👋

I am seeing an issue on Web (/admin/marketing) that I believe is related to this issue. Currently, in production, we are seeing out loading state appear briefly inside the Markup for the banner.
firey _ Aperçu du marketing _ Shopify 2020-01-30 10-29-21

This is what it looks like briefly before it goes back to its normal state.

I cannot seem to replicate it locally unless we do a production build of Web.

We are currently using a production build to see if there is anything we can do on Web to fix it there, but I thought I would ping here.

@ghost
Copy link

ghost commented Jul 28, 2020

This issue has been inactive for 180 days and labeled with Icebox. It will be closed in 7 days if there is no further activity.

@ghost ghost added the Icebox label Jul 28, 2020
@alex-page alex-page removed the Icebox label Jul 28, 2020
@BPScott
Copy link
Member

BPScott commented Jul 28, 2020

Still haven't found the time to polish this off. Waiting for the next version of react and replacing our useUniqueId hook with useOpaqueIdentifier once it becomes stable is gonna be the long term solution.

Components that don't yet use useUniqueId are tracked in #1995

@BPScott
Copy link
Member

BPScott commented Jul 28, 2020

Actually, gonna close this as a duplicate of #1761 as that's got a more up-to-date state of the world

@BPScott BPScott closed this as completed Jul 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken and not working as intended in the system.
Projects
None yet
Development

No branches or pull requests

6 participants