RegisterContainer.tsx
1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import React, { useState, useEffect } from "react";
import { RouteComponentProps } from 'react-router-dom';
import { useRecoilValue, useRecoilState } from "recoil";
import * as recoilUtil from '../../util/recoilUtil';
import Header from '../../components/Header';
import RegisterPresenter from "./RegisterPresenter";
import { authApi } from '../../api';
// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface RegisterProps extends RouteComponentProps {}
const RegisterContainer = (props : RegisterProps) => {
const [token, setToken] = useRecoilState(recoilUtil.token);
const fetchData = async() => {
if(token && token.length) {
const result = await authApi.verifyToken(token);
if (result.statusText === 'OK') {
props.history.push('/');
}
}
};
useEffect(() => {
fetchData();
}, []);
return (
<>
<Header {...props}/>
<RegisterPresenter
/>
</>
)
};
export default RegisterContainer;