mui / mui/material-ui

[TextField] Print warning in console if lots of Inputs are mounted at once with pointer to disableInjectingGlobalStyles docs

Open
#46,223 5 comments 0 reactions 1 assignee View on GitHub

Nobody has claimed this yet.

performance scope: text field
Dominant language
JavaScript
Stars
99.1k
Forks
32.5k
Avg merge
2d 17h
Merged PRs (30d)
106

Description

Summary

The first time one runs into perf issues rendering hundreds of TextFields or Inputs, it's hard to figure out what the problem is. I'm only rendering several hundred text fields, yet the user experience is quite bad (page freezes for ~2 seconds)

It may seem like this problem has been sufficiently solved, but I didn't expect such poor performance out of the box or such an inelegant workaround to solve the problem.

MUI should at least log a warning in the console when performance is becoming a problem, with a link to the docs about how to fix it.

Examples

If more than 50 InputBases mount at once, MUI should log a warning message in the console like:

Warning: you are mounting a lot of InputBase components at once, which can cause performance problems. To work around this issue see https://mui.com/material-ui/react-text-field/#performance

Motivation

I wasted several hours trying to improve performance before realizing the issue was coming from TextField/Input adding global style tags and landing on issues about this.

It's nice that people added documentation about performance issues, but I never saw that section of the documentation.

It doesn't seem right that every developer who needs to mount hundreds of inputs should have to stumble around for a long time before finding this workaround.

Search keywords: disableInjectingGlobalStyles Input TextField

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.