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

defaultValue not working for @material-ui TextField #2954

Closed
masbaehr opened this issue Jan 23, 2021 · 1 comment · Fixed by #2957
Closed

defaultValue not working for @material-ui TextField #2954

masbaehr opened this issue Jan 23, 2021 · 1 comment · Fixed by #2957
Labels

Comments

@masbaehr
Copy link

masbaehr commented Jan 23, 2021

I noticed a difference in Render output (react vs preact) when using https://github.com/mui-org/material-ui Textfield.

In case this is due to an implementation error in https://github.com/mui-org/material-ui let me know and i will create an issue there.
But since it is working fine in react 16 i think it's rather a preact issue.

Preact tested: "preact": "^10.5.11",
React tested: "react": "^16.14.0",

import React from "react";
import TextField from "@material-ui/core/TextField";

function Debug(props) {
  return <TextField label={"Name"} defaultValue="Hello" />;
}

export default Debug;

Note: Changing defaultValue to "value" works, but then obviously one would have to manage the state, which defeats the purpose of defaultValue (fast typing)

@chirag-ji
Copy link

This is still not working for me.

"react": "^18.1.0",
"react-dom": "^18.1.0",
"@material-ui/core": "^4.12.4",

The defaultValue is still not populating, and if using value; getting warning

Warning: A component is changing an uncontrolled input to be controlled. This is likely caused by the value changing from undefined to a defined value, which should not happen. Decide between using a controlled or uncontrolled input element for the lifetime of the component. More info: https://reactjs.org/link/controlled-components

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants