reactjs - linking one component to another in react with if else condition. (without react-router) -


i new react, trying link page if condition true code this

     checkcred(){       for(var i=0; < details_array.length; i++){         var currentobject = details_array[i];         if (this.email.value === currentobject.username){             console.log('yes done it');            // link component named index. if above statement true            //            }         else{        //sorry credentials wrong           }          }    } 

here button connected link.

       <span onclick={this.checkcred.bind(this)} classname="button1" bsstyle="primary" bssize="large" > block </span> 

i dont know how connect page, when using react-router. directly going page without checking condition.

thus problem can solved {withrouter} code this.

          for(var i=0; < details_array.length; i++){         var currentobject = details_array[i];         if (this.email.value == currentobject.username && this.password.value == currentobject.password){             console.log('yes done it');              this.props.router.push('index');          } 

i hope everyone!!!

thanks


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -