请告诉我怎么解决这个问题
product.action.js
import axios from '../helpers/axios';
export const getProductsBySlug = (slug) => {
return async dispatch =>{
const res = await axios.get(`/products/${slug}`);
console.log(res);
}
}
productListPage
[![enter image description here](https://i.stack.imgur.com/cxmbI.png)](https://i.stack.imgur.com/cxmbI.png)
import React, { useEffect } from "react";
import { useDispatch } from "react-redux";
import { getProductsBySlug } from "../../actions";
import Layout from "../../components/Layout";
/**
* @author
* @function ProductListPage
**/
export const ProductListPage = (props) => {
const dispatch = useDispatch();
useEffect(() => {
const { match } = props;
dispatch(getProductsBySlug(match.params.slug));
}, []);
return <Layout>Product List Page</Layout>;
};
我不明白是什么问题,所以我收到一条错误消息- TypeError:无法读取未定义的属性(正在阅读“params”)
1条答案
按热度按时间7hiiyaii1#
试着把额外的检查和调度时,鼻涕虫成为可用
希望能有所帮助