Skip to content
This repository has been archived by the owner on Dec 23, 2022. It is now read-only.

Server side rendering issue #59

Closed
GlebVST opened this issue Dec 15, 2016 · 1 comment
Closed

Server side rendering issue #59

GlebVST opened this issue Dec 15, 2016 · 1 comment
Labels

Comments

@GlebVST
Copy link

GlebVST commented Dec 15, 2016

Hi all,

Faced an issue when using this great component in a "universal" rendering environment.
Version 0.11.2 would assign a unique ID to the input field using a random generator which obviously doesn't produce a consistent ID on both server and client:

const uniqueId = `${name}-${hintText}-${floatingLabelText}-${Math.floor(Math.random() * 0xFFFF)}`;
this.uniqueId = uniqueId.replace(/[^A-Za-z0-9-]/gi, '');

What was the idea of using such artificial string instead of having a standard "id" prop as other material-ui components does (and specifically AutoComplete component)?
Can we leave the random id as default but prefer on using id prop when specified like:

<ChipInput id="123123" ... />

Currently getting a following result:

Warning: React attempted to reuse markup in a container but the checksum was invalid. This generally means that you are using server rendering and the markup generated on the server was not what the client was expecting. React injected new markup to compensate which works but you have lost many of the benefits of server rendering. Instead, figure out why the markup being generated is different on the client or server:
 (client) ormorepracticeareas-14803" data-reactid=
 (server) ormorepracticeareas-3326" data-reactid="

Thanks!
Gleb

@leMaik
Copy link
Member

leMaik commented Dec 15, 2016

Had a similar issue yesterday; using id if specified, like Material-UI's components do, sounds like a good solution. I'll fix that soon.

@leMaik leMaik added the bug label Dec 15, 2016
@leMaik leMaik closed this as completed in cea8d7b Dec 18, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants