Z
Z
Zhanna_K2020-09-26 13:53:08
React
Zhanna_K, 2020-09-26 13:53:08

Props did not come from the parent. Why?

I have a container component

const HeaderContainer = (props) => {
  console.log("header  container props", props.isLoggedIn);
  return <Header isLoggedIn={props.isLoggedIn} />;
};

const mapStateToProps = (state) => {
  return {
    isLoggedIn: Boolean(state.Session.id),
  };
};
export default connect(mapStateToProps, null)(HeaderContainer);


and presentation
const Header = (props) => {
  console.log("header props", props.isLoggenIn);
  return (
    <div className={s.header}>
      {props.isLoggenIn ? (
        <span>
          <a href='/auth' onClick={() => logoutUser()}>
            <span>Log Out</span>
          </a>
        </span>
      ) : (
        <div>Log in </div>
      )}
    </div>
  );
};

Here's what's printed to the console:
5f6f1ca59adb0802637490.png

Why is it that if the parent value is true>, the child's value is undefined ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Zenkovich, 2020-09-26
@Zhanna_K

You have a typo in your code. The container one says isLoggedIn and the presentation one says isLoggenIn

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question