question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[TextField] uniqueId breaks server rendering

See original GitHub issue

Problem Description

The unique ID that is generated on textfields seems to break server rendering. The generated html looks like this:

<input
  name="query"
  id="query-MerchantEmailAddress-undefined-19669"
  style="-webkit-tap-highlight-color:rgba(0,0,0,0);padding:0;position:relative;width:100%;height:100%;border:none;outline:none;background-color:rgba(0,0,0,0);color:rgba(255, 255, 255, 1);font:inherit;mui-prepared:;"
  type="text"
  data-reactid=".s5vj4rstmo.0.$=10=2$=011.$=10.1.0.$=10.2"
>

I am getting the standard react checksum error:

warning.js:45 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) ilAddress-undefined-19669" style="-webki
 (server) ilAddress-undefined-46463" style="-webki

Versions

  • Material-UI: 0.15.0-alpha.2
  • React: 0.14.7
  • Browser: Chrome

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:16
  • Comments:18 (14 by maintainers)

github_iconTop GitHub Comments

2reactions
oliviertassinaricommented, Oct 4, 2016

@nathanmarks have made the link between the label and the input more explicit on the next branch. E.g.

<TextField>
  <TextFieldLabel htmlFor="name">
    Name
  </TextFieldLabel>
  <TextFieldInput
    id="name"
    value={this.state.value}
    onChange={(event) => this.setState({ value: event.target.value })}
  />
</TextField>

Making the link more explicit allow us to remove the magic uniqueId generation. And solve the server-side rendering issue. I’m closing this issue as well as https://github.com/callemall/material-ui/pull/4253.

2reactions
petermikitshcommented, Sep 25, 2016

Adding to @halt-hammerzeit’s comment, adding an id prop to TextField solved the issue for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[TextField] uniqueId breaks server rendering · Issue #3757
Problem Description The unique ID that is generated on textfields seems to break server rendering. The generated html looks like this:
Read more >
Prop mismatch server/client, how to generate a unique ID ...
I'm using ReactJS.net with server rendering. I want to make a simple component that outputs a label and an input where the label...
Read more >
Add server-side unique-ID or unique token validations
Overview: Implement an "advanced" server-side validation for the field. The field should have a randomly generator token which is bound to ...
Read more >
Links in displayed text that break unwanted browser caching - ...
Problem: On a WP server configured for browser caching, I have a “Gateway Page” that renders an HTML field with two different sets...
Read more >
Best practices for unique identifiers
This document provides guidance for selecting appropriate identifiers for your app based on your use case. For a general look at Android permissions, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found