Я создаю приложение реагирования, и когда мое приложение запускается, я хочу знать, вошел ли пользователь, чтобы отправить его на домашнюю страницу. Когда мое приложение запускает маршрут "/", загрузите эту страницу
import React from 'react';
import { Redirect } from 'react-router';
import { LocalStorageService } from "../services/localData-service";
const HomeOrLogin : React.FC = () => {
/*If User is logged then, redirect to home, if not redirect to slides tutorial*/
const storageService = new LocalStorageService();
// Check if exits jwt in the phone
storageService.getItem("jwt")
.then((token )=>{
/* If exists the jwt in the phone the user is logged */
if(token){
return <Redirect to="/Home" />
}else{
return <Redirect to="/slides" />
}
})
.catch((err)=>{
console.log(err);
})
};
export default HomeOrLogin;
Но оно показывает ошибку в компоненте
Type '() => void' is not assignable to type 'FC<{}>'.
Type 'void' is not assignable to type 'ReactElement<any, any> | null'.