I'm unable to push the id with history.push But if I don't add id then it works fine. I'm using react-router-dom v5
useEffect(() => {
fetchData();
if (!userInfo) {
history.push("/login"); // This portion works
} else if (successCreate) {
history.push(`/order/${order.id}`); // This does not work as expected
}
}, [userInfo, history]);
// Here if I don't use order.id then it works, However I can console the order.id and it displays the id properly. Is there any alternative to do the same thing in react. ? Or how to fix this issue