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.

<Input> disable in <TextField> not working

See original GitHub issue

I get the following error when i toggle disable <TextField> input:

Uncaught Error: MDCReactTextField: The input did not render properly
    at Object.getNativeInput (VM3816 index.js:300)
    at MDCTextFieldFoundation.getNativeInput_ (VM3816 index.js:559)
    at MDCTextFieldFoundation.setDisabled (VM3816 index.js:531)
    at Input.226.Input.componentDidUpdate (VM3816 index.js:775)
    at commitLifeCycles (VM1337 react-dom.development.js:17303)
    at commitAllLifeCycles (VM1337 react-dom.development.js:18690)
    at HTMLUnknownElement.callCallback (VM1337 react-dom.development.js:149)
    at Object.invokeGuardedCallbackDev (VM1337 react-dom.development.js:199)
    at invokeGuardedCallback (VM1337 react-dom.development.js:256)
    at commitRoot (VM1337 react-dom.development.js:18902)
    at eval (VM1337 react-dom.development.js:20372)
    at Object.unstable_runWithPriority (VM1344 scheduler.development.js:255)
    at completeRoot (VM1337 react-dom.development.js:20371)
    at performWorkOnRoot (VM1337 react-dom.development.js:20300)
    at performWork (VM1337 react-dom.development.js:20208)
    at performSyncWork (VM1337 react-dom.development.js:20182)
    at interactiveUpdates$1 (VM1337 react-dom.development.js:20449)
    at interactiveUpdates (VM1337 react-dom.development.js:2170)
    at dispatchInteractiveEvent (VM1337 react-dom.development.js:4882)

This is sample code:

import React, { useState } from "react";
import { render } from "react-dom";
import TextField, { Input } from "@material/react-text-field";
import Button from "@material/react-button";

import "./styles.css";

const App = () => {
  const [toggle, setToggle] = useState(false);
  const onToggle = () => {
    setToggle(!toggle);
  };
  return (
    <div className="App">
      <TextField label="test">
        <Input disabled={toggle} value="1234" />
      </TextField>
      <Button outlined onClick={onToggle}>
        toggle disable
      </Button>
    </div>
  );
};

const rootElement = document.getElementById("root");
render(<App />, rootElement);

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
TroyTaecommented, May 4, 2019

Maybe we need to consider observer or singleton pattern for preventing like this situation.

0reactions
moog16commented, May 6, 2019

Closing with #848

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to disable an input type=text? - javascript - Stack Overflow
Working example:​​ Show activity on this post. You can get the DOM element and set disabled attribute to true/false. If you use vue...
Read more >
HTML input disabled Attribute - W3Schools
The disabled attribute is a boolean attribute. When present, it specifies that the <input> element should be disabled. A disabled input element is...
Read more >
Disable TextFields Then Enable Them - Apple Developer
This is the code I have its similar to the example in my textFieldShouldReturn function. I don't have the textFields empty as default....
Read more >
Disable and enable an input text box with JavaScript/jQuery
This post will discuss how to disable and enable an input text box in JavaScript and jQuery. When the element is disabled, it...
Read more >
How to Set the Disabled State in React TextBox component
Disable the TextBox by adding the e-disabled to the input parent element and set disabled attribute to the input element. ... Is this...
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