Skip to content

Commit 2ebbfc7

Browse files
committed
more fixes
1 parent 2c2ae19 commit 2ebbfc7

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/App.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ import { WithWidth } from "@material-ui/core/withWidth";
55
import { makeStyles } from "@material-ui/styles";
66
import * as React from "react";
77
import { connect } from "react-redux";
8-
import { Route, RouteComponentProps, Router } from "react-router-dom";
8+
import { Route, Router } from "react-router-dom";
99
// config
10-
import { history } from "./redux/configureStore";
1110
import { RootState } from "./redux/rootReducer";
1211
import withRoot from "./withRoot";
1312
// hoc
@@ -28,7 +27,7 @@ function Routes() {
2827
);
2928
}
3029

31-
interface Props extends RouteComponentProps<void>, WithWidth { }
30+
interface Props extends WithWidth { }
3231

3332
function App(props?: Props) {
3433
const classes = useStyles();
@@ -37,7 +36,7 @@ function App(props?: Props) {
3736
}
3837

3938
return (
40-
<Router history={history}>
39+
<Router>
4140
<div className={classes.root}>
4241
<div className={classes.appFrame}>
4342
<Routes />

src/pages/Login/Login.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React, { useState, useEffect } from "react";
22
import { bindActionCreators } from "redux";
33
import { connect } from "react-redux";
4-
import { RouteComponentProps } from "react-router-dom";
54

65
// material ui
76
import Avatar from "@material-ui/core/Avatar";
@@ -20,6 +19,7 @@ import * as LoginActions from "../../redux/authentication/authenticationActions"
2019
// elements
2120
import FieldUsername from 'elements/FieldUsername/FieldUsername';
2221
import FieldPassWord from 'elements/FieldPassword/FieldPassword';
22+
import { useNavigate } from "react-router-dom";
2323

2424
const styles = (theme: Theme) => createStyles({
2525
main: {
@@ -54,18 +54,19 @@ const styles = (theme: Theme) => createStyles({
5454
});
5555

5656

57-
interface Props extends RouteComponentProps<any> {
57+
interface Props {
5858
classes: any;
5959
todoList: Todo[];
6060
actions: typeof LoginActions;
6161
token: string | null;
6262
}
6363

6464
function Login(props: Props) {
65-
console.log(props);
6665
const { classes } = props;
6766
const [username, setUsername] = useState("");
6867
const [password, setPassword] = useState("");
68+
const navigate = useNavigate();
69+
6970

7071
const handleSubmit = (event: any) => {
7172
event.preventDefault();
@@ -76,7 +77,7 @@ function Login(props: Props) {
7677
};
7778
useEffect(() => {
7879
if(props.token) {
79-
props.history.push('/listing');
80+
navigate('/listing');
8081
}
8182
});
8283
return (

0 commit comments

Comments
 (0)