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

326
Views
How to parse '<NavLink className={({ isActive }) => isActive ? "red" : "blue"} />'?

I think I understand why the first instance of isActive that's passed as an argument to the arrow function is encapsulated in curly brackets, i.e. { isActive }, while the second isActive is not encapsulated in curly brackets, but would like to be sure I understand correctly.

Is the first "isActive" that's encapsulated in curly brackets i.e., ({ isActive }) an example of Object Destructuring ? (If not, doesn't an arrow function in JS expect to receive the name of a variable, but doesn't { isActive } evaluate to true or false?)

Am I right that this is an example of Object Destructuring?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Your understanding is right. react-router v6 has changed the NavLink API a bit. You need to provide the isActive wrapped in an object as opposed to in NavLink v5.

export interface NavLinkProps
  extends Omit<LinkProps, "className" | "style" | "children"> {
  children:
    | React.ReactNode
    | ((props: { isActive: boolean }) => React.ReactNode);
  caseSensitive?: boolean;
  className?: string | ((props: { isActive: boolean }) => string | undefined);
  end?: boolean;
  style?:
    | React.CSSProperties
    | ((props: { isActive: boolean }) => React.CSSProperties);
}
over 4 years ago · Santiago Trujillo 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!