Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 140273

Redux Store: cannot read property and store is undefinied

$
0
0

I start working in a redux project with redux and it's an entirely chaos, I set up an a Store as interface, like this:

interface Store {
  ads: {
    loading: boolean;
    data: Ad[];
    errors: Error;
    isPro: boolean; 
  };
}

interface Ad {
  id: any;
  title: any;
  body: any;
  price: any;
  latitude: any;
  longitude: any;
}

I have this constant to refer as an action to dispatch after:

export const TYPE_ADD_JOB_ANNOUNCEMENT_REQUEST = "action/addJobAnnouncementRequest";

And then i have my reducer:

case TYPE_ADD_JOB_ANNOUNCEMENT_REQUEST:
  console.log("Test add job");
  return {
    ...Store,
    [...Store.ads.data, ...action.payload]
  };

I already the ReduxDevTools working, i test it with different console log and it work fine, now why when the reduxdevotools try to dispatch an action with the payload, (Example:

{
  type: 'action/addJobAnnouncementRequest',
  payload: { title: "test" }
}

It give me different errors if i try different test but with the same mode, like

store is undefinied,

or

cannot read property "ads"

I think there is a problem with my javascript syntax or i dont know, can anyone help me?


Viewing all articles
Browse latest Browse all 140273

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>