targetMovie is null when it comes to rednering. I couldn't find any solutions. First time having unsolvable problem. Please help!
async function getMovie(id) {
try {
const res = await axios.get(apiEndPoint + "/" + id);
const movies = await res.data;
return movies;
} catch (err) {
console.log(err);
}
}
const MovieEdit = () => {
const { id } = useParams();
const [targetMovie, setTargetMovie] = useState(null);
useEffect(() => {
getMovie(id)
.then((mov) => {
setTargetMovie(mov);
console.log(mov);
})
.catch((err) => console.log(err));
}, []);
console.log(targetMovie);
if (targetMovie) return <AddMovie movie={targetMovie} />;
return <Navigate to="/not-found" />;
};