This is my example code.
import React, { Component } from "react";
import Navpills from "./Navpills";
import Home from "./pages/Home";
import About from "./pages/About";
import Blog from "./pages/Blog";
import Contact from "./pages/Contact";
class PortfolioContainer extends Component {
state = {
currentPage: "Home"
};
handlePageChange = page => {
this.setState({ currentPage: page });
};
render() {
return (
<div>
<Navpills
currentPage={this.state.currentPage}
handlePageChange={this.handlePageChange}
/>
Based on `this.state.currentPage`, render the appropriate component
here.
</div>
);
}
}
export default PortfolioContainer;
The instructions are as follows:
Now add code to PortfolioContainer so that depending on the currently selected page, a different component is rendered underneath the Navpills component. Example:
Render the
Aboutcomponent whenthis.state.currentPage === "About"Render the
Blogcomponent whenthis.state.currentPage === "Blog"Render the
Contactcomponent whenthis.state.currentPage === "Contact"Render the
Homecomponent whenthis.state.currentPage === "Home"