hello. i have a very simple react native component, and i assign a ref with ref={r => this.label = r}. then i also have a function where inside i do things to this.label.
now flow complains that property label is not found.
Add a type def for label.
Yeah, what @nmn said. Without more information it's hard to say what's going wrong. Feel free to re-open with a repro case.
so like 锘匡豢ref={r => this.label: string = r}? where do i set the type? and what type is a ref?
Do we do it like this?
class Login extends Component {
props: Props
email: HTMLInputElement
password: HTMLInputElement
render() {
<input type="email" placeholder="Email" ref={(input) => { this.email = input }} />
<input type="password" placeholder="Password" ref={(input) => { this.password = input }} />
}
}
ah cool. i will try it and report back. thanks.
Is think that solution is only possible when using React classes, is there a chance of doing this in stateless functional components?
function Login = ({ email, password }) => (
<input type="email" placeholder="Email" ref={(input) => { this.email = input }} />
<input type="password" placeholder="Password" ref={(input) => { this.password = input }} />
)
The above example will trigger property 'email'. Property not found in ^^^^ global object
Most helpful comment
Is think that solution is only possible when using React classes, is there a chance of doing this in stateless functional components?
The above example will trigger
property 'email'. Property not found in ^^^^ global object