reactjsreduxstoremapdispatchtoprops

Why is the Redux store state variable a function also or did I miss something here


I am learning React and JavaScript.

I have this Redux Store that looks like this very simple:

const initialState = {
  booksList: [],
  progress: false,
  faild: "",
  log: ""
};

When I do mapStateToProps to my Component then I don't get a log='' but I get something else. Basically what I try to do is this if(log != "") as the image show but I get a true when I want to get a false because initial Store is empty.

As the image show the log also contains a function the Redux store dispatch.

enter image description here


Solution

  • Currently the log parameter corresponds to your component properties (containing two properties log and dispatch)

    You must declare your component like this :

    function Logger({log}) {
      ...
    } 
    

    or like this

    function Logger(props) {
      const log = props.log;
      ...
    }