The following code uses RTK query to create a Redux Hook:
export const specialtiesApi = createApi({
reducerPath: 'specialtiesApi',
baseQuery: fetchBaseQuery({ baseUrl: 'https://someplace.com/' }),
endpoints: (builder) => ({
getSpecialties: builder.query({
query: (name) => `specialties`,
}),
}),
});
export const { useGetSpecialtiesQuery } = specialtiesApi;
The last line of code throws a Typescript compile-time error:
Property 'useGetSpecialtiesQuery' does not exist on type 'Api<BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError, {}, FetchBaseQueryMeta>, { getSpecialties: QueryDefinition<...>; }, "specialtiesApi", never, unique symbol>'
My code is adapted from https://redux-toolkit.js.org/rtk-query/usage-with-typescript using Typescript 4.3.5.
I can't see what's wrong with it. Any ideas?