reactjs - Two different header components in React? -
just quick question. i'm creating react app needs have different rendition of header. on login page it's header logo (the form different component) , when user logged, header gets , menu , logout button. need 2 different headers/components or 1 conditional rendering?
thanks.
you create wrapper component:
class loginheader extends react.component { render() { return <div>i'm login header!</div> } } class otherheader extends react.component { render() { return <div>i'm other header!</div> } } class header extends react.component { render() { return isloggedin() ? <otherheader /> : <loginheader /> } }
code nicely separated way
Comments
Post a Comment