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

46 views Asked by At

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

2

There are 2 answers

2
Olivier Boissé On BEST ANSWER

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;
  ...
} 
0
phry On

In JavaScript, undefined == "" returns true.

You want to use the operators === and !== instead of == and !=.