-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[TextField] add ref callback #6893
Comments
This behaviour is explained by the fact that |
Following the React docs... works for me, but I get warnings. Is there any advantage in using Ref or onChange methods? // CustomTextField component
import React, { Component } from 'react'
import TextField from 'material-ui/TextField'
export default (props) => (
<div>
<TextField {...props} ref={props.inputRef} />
</div>
) import React, {Component} from 'react'
import CustomTextField as TextField from '../TextField'
class LoginBox extends Component {
constructor() {
super()
}
send(event) {
event.preventDefault()
console.log(this.email.input.value
console.log(this.password.input.value})
}
render() {
return (
<div>
<form onSubmit={this.send.bind(this)}>
<div>
<TextField
name="email"
type="email"
inputRef={el => this.email = el}
/>
<TextField
name="password"
type="password"
inputRef={el => this.password = el}}
/>
<input type="submit" value="Send" />
</div>
</form>
</div>
);
}
} warning.js?9398f22:36 Warning: Unknown prop
|
@maisumbruno My issue concerns the |
@jgoux What about? <TextField
inputProps={{
ref: (node) => { console.log('node', node); },
}}
/> |
Well, that won't work yet. I'm on it. |
I think that exposing a |
@jgoux Which Autocomplete component? |
Thanks for the I'm still missing the ref to the root node of @Nagle This one : https://codesandbox.io/s/oQ0nkl5pk |
You can try |
I'm curious, why adding a new prop like |
@jgoux The component is already a class so you can always get a ref. |
I'm not sure I follow. I tried adding a |
Functional components do not support ref callback. |
Use can do this by using inputRef |
I was needing ref to get the input value , i did the simple trick after passing the ref to material ui text field. <TextField I used the this to get the value let sPassword = this.refs.password.input.value; |
Not sure if I had the same issue as the original issue but my search for a solution led me here. With RootRef as a wrapper I got the DOM ref I needed. |
Problem description
The
TextField
component ref's callback returnsnull
instead of the root node of the component.More globally, it would be great to have this callback on every Material UI's components.
Link to minimal working code that reproduces the issue
https://codesandbox.io/s/kzJWNlX5
Versions
The text was updated successfully, but these errors were encountered: