Home > database >  When i trying for a form validate im getting this error (Property 'email' does not exist o
When i trying for a form validate im getting this error (Property 'email' does not exist o

Time:09-24

    interface IRegisterProps {
  navigation: any;
}

interface IRegisterState { }


class RegisterScreen extends React.PureComponent<IRegisterProps, IRegisterState> {

  constructor(props: any) {
    super(props);
    this.state = {
      nick: "",
      nickError: ""
    };
  }
nickValidator(){
  if(this.state.mail=""){
    
  }
}

when im trying to do validate im geeting this error: Property 'email' does not exist on type 'Readonly<{}>'

if(this.state.mail=""){ this is my error line

CodePudding user response:

While comparing, you can't assign a value to variable, use == instead

 if(this.state.mail==""){

Also please cross check if it's mail or email in your state and change the condition accordingly

Secondly, add property email to your state

this.state = {
  ...
 email: ''
};

or make it type of any

this.state: any = {
  ...
};

If you using interface in the state that define the property in the interface too

interface IRegisterState {
   email: string
}
  • Related