@@ -210,6 +210,8 @@ export const selectDataByName = (state: RootState, name: string) =>
210210 state .pokemon .dataByName [name ]
211211
212212// file: src/store.ts noEmit
213+ import { useDispatch } from ' react-redux'
214+ import { EnhancedStore } from ' @reduxjs/toolkit'
213215interface Pokemon {}
214216type RequestState = ' pending' | ' fulfilled' | ' rejected'
215217
@@ -221,10 +223,14 @@ export type RootState = {
221223 pokemon: typeof initialPokemonSlice
222224}
223225
226+ export declare const store: EnhancedStore <RootState >
227+ export type AppDispatch = typeof store .dispatch
228+ export declare const useAppDispatch: () => (... args : any [])=> any ;
229+
224230// file: src/hooks.ts
225231import { useEffect } from ' react'
226- import { useDispatch , useSelector } from ' react-redux'
227- import { RootState } from ' ./store'
232+ import { useSelector } from ' react-redux'
233+ import { RootState , useAppDispatch } from ' ./store'
228234import {
229235 fetchPokemonByName ,
230236 selectStatusByName ,
@@ -233,7 +239,7 @@ import {
233239
234240// highlight-start
235241export function useGetPokemonByNameQuery(name : string ) {
236- const dispatch = useDispatch ()
242+ const dispatch = useAppDispatch ()
237243 // select the current status from the store state for the provided name
238244 const status = useSelector ((state : RootState ) =>
239245 selectStatusByName (state , name )
0 commit comments