I am having an issue where my page doesn't refresh when I call the refresh function I passed.
function ProductsPage(props) {
const [products, setProduct] = useState([])
const [shouldRefresh, setRefresh] = useState(false)
function refreshProducts() {
setRefresh(!shouldRefresh)
}
const token = localStorage.getItem("token")
const headers = { Authorization: "Token " + token }
useMemo(() => (axios.get("/products", { headers: headers }).then((resp) => (
setProduct(resp.data)
))
), shouldRefresh)
return (
<Box className="cardDeck">
<Redirect_if_not_logged_in />
{products.map((product) => (
<InfoCard product={product} refresh={refreshProducts}></InfoCard>
)).reverse()}
</Box>
)
}
Whenever I call props.refresh() from the InfoCard, nothing happens.