Get arguments from another component [React JS]

I’m creating a web-app using React. I’m facing a problem with my navbar and the main content. Let’s see the problem:

In AppWrapper I have this:

var contents = [
   <Offers />,
   <Create />,
   <List />
];

where each item will be the content displaying.

In getInitialState I initialize it:

getInitialState: function() {
  return {
    currentTab: 0
  };
},

Later, in render function I have this:

return (
  <div>
    <Navbar />
    <div className='mainPanel'>
      {contents[this.state.currentTab]}
    </div>
  </div>
);

See that I call the navbar component before the content.

In Navbar component I have a menu where, from there, I want to change the currentTab of AppWrapper.

How can I do that? Thank you for advance!


Source: javascript

Leave a Reply