im using react router
on my project, when i hit the login button, it renders
the content of App
component, but displays them on the same page
. i want to display on new page
when i hit login
, help me
import React, { Component } from 'react';
import * as service from '../services/service';
import '../App.css'
import '../index.css'
import App from'../App'
import { Link, Redirect, Router, Route, browserHistory,IndexRoute } from 'react-router';
// import createHistory from 'history/createBrowserHistory'
class Login extends Component {
constructor(props) {
super(props);
this.state = {
messages: []
}
}
onSubmit() {
browserHistory.push('/world');
}
render() {
const { messages } = this.state;
return (
<div className="App">
<header>
<h2> Doctor Login Page </h2>
</header>
<form>
<Router history={browserHistory}>
<Route path="/world" component={App}/>
</Router>
<br /><br /><br />
Username: <input name='email' placeholder='Email' /><br /><br />
Password: <input name='password' placeholder='Password' type='password' />
<br /><br />
<button onClick={() => this.onSubmit()}>Login</button>
</form>
</div>
);
}
}
export default Login;