In Reg.js
Import React, {Component} from "React"class Reg extends component{render () {return( <div> <ul> <li><label> user name: </label><input/></LI&G T <li><label> Password: </label><input/></li> <li><label> Email: </label ><input/></li> <li><label> Mobile: </label><input/></li> <li><button> Registration </button></li> <li><button onclick={ This. Tologin.bind ( This)}> to login </button></li> </ul> </div> ) } //ControllerTologin () { This. Props.history.push ("/login")}}exportdefaultReg;
In the Login.js file
Import React, {Component} from "React"Import {Link} from' React-router-dom '; class Login extends component{render () {return( <div> <ul> <li><label> user name: </label><input/></LI&G T <li><label> Password: </label><input/></li> <li><button onclick={ This. Tomain.bind ( This)}> login </button></li> <li><link to= "/reg" > Go to Registration </Link></li> {/*<li><button Onclick={this.toreg.bind (this)}> go to register </button></li>*/} </ul> </div> ) } //ControllerTomain () { This. Props.history.push ("/main")} toreg () { This. Props.history.push ("/reg")}}exportdefaultLogin;
In Main.js
Import React, {Component} from "React"Import Quest from'./quest/stwo 'Import Goods from'./shop/shopt '; import {Hashrouter as Router, Route,link} from' React-router-dom '; class Main extends component{render () {return( <div> <div> <ul> <li><link to= "/main/a 1 "> Full minus </Link></li> <li><link to="/MAIN/A2 "> 50 percent </Link></li> </ul> </div> <Router> <div> <route path= '/main/a1 ' component={quest}/> <route path= '/main/a2 ' compo Nent={goods}/> </div> </Router> </div>)}}exportdefaultMain;
In Index.js
Import React from ' React 'react-dom'./main './reg './login '; import { Hashrouter as Router, ' react-router-dom '; // Login Registration Reactdom.render ( <Router> <div> <route path= '/reg ' Component={reg}/ > <route path= '/login ' Component={login}/> <route path= '/main ' Component={main}/> </div> </Router>), document.getElementById (' root ');
Shopping cart combined with single page Web application