cant use useParams() ?
Unanswered
ani posted this in #help-forum
aniOP
const [cakes, setCakes] = useState<any[]>([]);
const id = useParams().id;
useEffect(() => {
fetch("/api/cakes/")
.then((response) => response.json())
.then((data) => setCakes(data))
.catch((error) => console.error(error));
}, []);
const cake = cakes[id - 1];and here is the error
1 Reply
aniOP
Used routed