skip to Main Content

@reduxjs/toolkit – UseSelector returning Undefined instead of Google Username – Javascript

store/index.js import { configureStore } from "@reduxjs/toolkit"; import rootReducer from "../reducers/index"; const store = configureStore({ reducer: { user: rootReducer, }, middleware: (getDefaultMiddleware) => getDefaultMiddleware({ serializableCheck: false, }), }); export default store; userSlice.js import { createSlice } from "@reduxjs/toolkit"; export const…

VIEW QUESTION

fetch data to Redux state – Reactjs

is it possible to add data to redux state this method: const dispath = useDispatch(); useEffect(() => { fetch(`https://newsapi.org/v2/top-headlines?country=${location.state}&apiKey=${apiKey}`) .then(res => res.json()) .then(data => { setNewsAll(data) console.log(data) setLoadingNews(false) dispath(data.totalResults) // <= this line ! i know that it must be…

VIEW QUESTION
Back To Top
Search