I have implemented useHistory() same as i implemented below , previously i didnt get any error but in this compmonent i am getting an error as
Line 6:18: React Hook "useHistory" is called in function "showPost" which is neither a React function component or a custom React Hook function react-hooks/rules-of-hooks
import React from 'react';
import CloseIcon from '@material-ui/icons/Close';
import {useHistory} from 'react-router-dom';
const showPost = () =>{
let history = useHistory();
const closeUpload = () =>{
history.goBack();
}
return(
<div className="overlay">
<div className="overlay-container">
<button className="close-btn" onClick = {closeUpload}><CloseIcon color="action"/></button>
<h1>Hello</h1>
</div>
</div>
);
}
export default showPost;
please, help me in solving this. thank you in advance.