How to pass props down to child component in React

So in my main component, I send props to a child component like this:

<div className={styles.navBar}>
          <MasterNavBar color={false} scrollChange={true} />

MasterNavBar gets access to the props correctly, but I need MasterNavBar to pass those props to a child component called NavBar, which I currently do like this:

<NavBar props />

However, when I do this, the props are not accessible in my NavBar component file. For example, in NavBar, doing props.color to get my color prop returns undefined. So, am I passing my props incorrectly, or am I missing something else?

Source: React – Stack Overflow

November 19, 2021
Category : News
Tags: javascript | react-component | react-props | reactjs

Leave a Reply

Your email address will not be published. Required fields are marked *

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.