Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

183
Views
How to display two react components

This is my first time using React and need some help. I have a TextEditor component and a Navbar component in my App.js class. I am trying to get both to display on my page, but only see the TextEditor component. When this component is removed i can then see the Navbar component. How can i see both components on my page?

class App extends Component {
  render() {
  return (
    <Router>
    <div className="App">
      <Switch>
        {/* Navbar */}
        <Route exact path="/" component={Navbar} />
        <Navbar bg="light" expand="sm"/>
        {/* Home page */}
        <Route path="/" exact> 
          <Redirect to={`/documents/${uuidV4()}`} />
        </Route>
        {/* TextEditor */}
        <Route path="/documents/:id" component={TextEditor}> 
          <TextEditor />
        </Route>
      </Switch>
      </div>
    </Router>
  )
  }
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

try this code, this add header on every your page with put component Navbar outside Switch

class App extends Component {
  render() {
    return (
        <Router>
            <div className="App">
                {/* Navbar */}
                <Navbar bg="light" expand="sm"/>
                <Switch>
                    {/* Home page */}
                    <Route exact path="/"> 
                        <Redirect to={`/documents/${uuidV4()}`} />
                    </Route>
                    {/* TextEditor */}
                    <Route path="/documents/:id" component={TextEditor}> 
                        <TextEditor />
                    </Route>
                </Switch>
            </div>
        </Router>
    )
  }
}

or add header just with component TextEditor instead

class App extends Component {
  render() {
    return (
        <Router>
            <Switch>
            {/* Home page */}
            <Route exact path="/"> 
                <Redirect to={`/documents/${uuidV4()}`} />
            </Route>
            {/* TextEditor */}
            <Route path="/documents/:id" component={TextEditor}> 
                {/* Navbar */}
                <Navbar bg="light" expand="sm"/>
                <TextEditor />
            </Route>
            </Switch>
        </Router>
    )
  }
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!