I wonder why, after 5 seconds, it's redirect to a blank white page instead to the page that I want. I already called the function in return, but I guess it's not really working. Can someone help me?
import React from 'react'
import styled from 'react-emotion'
import { Redirect } from 'react-router-dom'
class ErrorPage extends React.Component {
state = {
redirect: false
}
componentDidMount() {
this.timeoutHandle = setTimeout(() => {
this.setState({
redirect: true
})
}, 5000)
}
renderRedirect = () => {
if (this.state.redirect === true) {
return <Redirect to="https://www.google.com/" />
}
}
render() {
return (
<ErrorContainer>
{this.renderRedirect()}
<ErrorText>Page Not Found</ErrorText>
<ErrorBox>
<ErrorDesc>We are sorry, but the page you are looking for does not exist</ErrorDesc>
</ErrorBox>
</ErrorContainer>
)
}
}
export default ErrorPage