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

120
Views
Should I be using functions instead of classes for pages in ReactJS?

I've noticed React Router DOM (v6) is now using functions in their help guides in regards to pages instead of using classes.

Previously used classes like so:

export class Login extends React.Component {
    render() {
        return <p>test</p>
    }
}

However, after trying the latest version of React Router DOM I would receive an empty page for the navigation route.

import {Login} from "./js/components/Auth/Login";


function App() {
    return <h2>Test</h2>
}

if (document.getElementById('app')) {
    ReactDOM.render(
        <BrowserRouter>
            <Routes>
                <Route path="/" element={<App />} />
                <Route path="/login" component={() => <Login />} />
            </Routes>
        </BrowserRouter>, document.getElementById('app'))
}

App works fine ('/' route), but /login returns an empty page with no error..

Login refers to a class that uses render() and returns <p>test</p>

Am I doing something incorrectly? Are libraries leaning towards functions instead of class components?

This guide seems to be only using functions for components.

https://reactrouter.com/docs/en/v6/getting-started/tutorial

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Class vs Function components is irrelevant in RRDv6, they simply render React components specified as JSX, not as a reference to a component, and not as a function returning JSX. There is also no render or component props, the Route components now use only element to render the route components.

<Routes>
  <Route path="/" element={<App />} />
  <Route path="/login" element={<Login />} />
</Routes>
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!