When I clicked on Submit button, It should redirect me to another page, Where my other all pages should display there.. This is the submit page, Where I written one function to redirect to Home page.
import React, {Component} from 'react';
import './App.css';
import { BrowserRouter, Route, Link } from 'react-router-dom';
import Home from './components/home';
class App extends Component {
constuctor() {
}
routeChange=()=> {
this.props.history.push("/Home");
}
render () {
return (
<div>
<center>
<div>
<label htmlFor="exampleInputEmail1">Email address : </label>
<input type="text" placeholder="Enter email"/>
</div>
<div>
<label htmlFor="exampleInputPassword1">Password : </label>
<input type="password" placeholder="Password" />
</div>
<button type="submit" onClick={this.routeChange} >Submit</button>
</center>
</div>
)
}
}
export default App;
This is my Home page,Where I have written code for routing for all other pages
import React, { Component } from 'react';
import { BrowserRouter, Route, Link } from 'react-router-dom';
import Posts from './posts';
import Profile from './profile';
class Home extends Component {
render() {
return (
<div>
<center>
<BrowserRouter>
<div>
<header>
<Link to="/">Home</Link>
<Link to="/Posts">Posts</Link>
<Link to="/Profile">Profile</Link>
</header>
<Route exact path ="/" component={Home}></Route>
<Route path ="/Posts" component={Posts}></Route>
<Route path ="/Profile" component={Profile}></Route>
</div>
</BrowserRouter>
</center>
</div>
)
}
}
When I clicked on Submit button , It should take me to other Page.