我正在制作coinnew use redux,我有一些问题,为什么它不是一个函数??
import HTMLReactParser from "html-react-parser";
import { useParams } from "react-router-dom";
import millify from "millify";
import { Col, Row, Typography, Select } from "antd";
import { useState } from "react";
import { useGetCryptoDetailsQuery } from "../services/coinDetailApi";
const { Title, Text } = Typography;
const { Option } = Select;
const CryptoDetails = () => {
const { coinId } = useParams();
console.log(coinId);
const [timePeriod, setTimePeriod] = useState("7d");
const { data, isFetching } = useGetCryptoDetailsQuery(coinId);
const cryptoDetails = data?.data?.coin;
return <div>CryptoDetails </div>;
};
export default CryptoDetails;
程序表示useGetCryptoDetailsQuery不是函数我不知道帮帮我!!
这是我的Api代码
const baseUrl = "https://coinranking1.p.rapidapi.com";
const createRequest = (url) => ({ url, headers: cryptoApiHeaders });
export const cryptoDetailsApi = createApi({
reducerPath: "cryptoApi",
baseQuery: fetchBaseQuery({ baseUrl }),
endpoints: (builder) => ({
getCryptoDetails: builder.query({
query: (coinId) => createRequest(`/coin/${coinId}`)
})
})
});
export const { usegetCryptoDetails } = cryptoDetailsApi;
这是我的还原码
import { configureStore } from "@reduxjs/toolkit";
import { cryptoApi } from "../services/coinApi";
import { cryptoDetailsApi } from "../services/coinDetailApi";
import { cryptoNewsApi } from "../services/coinNewsApi";
export default configureStore({
reducer: {
[cryptoApi.reducerPath]: cryptoApi.reducer,
[cryptoNewsApi.reducerPath]: cryptoNewsApi.reducer,
[cryptoDetailsApi.reducerPath]: cryptoDetailsApi.reducer
}
});
请帮帮我!!ㅜㅡㅜ
您导出了错误的钩子函数。有一个小打字错误。你没有大写";g";"中的字母";usegetCryptoDetails":
export const { usegetCryptoDetails } = cryptoDetailsApi;
应该是:
export const { useGetCryptoDetails } = cryptoDetailsApi;