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

257
Views
Typescript children throwing ESLint: 'children' is defined but never used.(no-unused-vars)

I'm getting an error with Typescript linting error on my custom ConditionalWrapper Component. The component will conditionally wrap another component based on a condition

Question: How can I properly type wrapper prop for type ConditionalWrapperProps?

import React from "react";

type ConditonalWrapperProps = {
  children: React.ReactElement;
  condition: boolean;
  // ESLint: 'children' is defined but never used.(no-unused-vars)
  wrapper: (children: React.ReactElement) => JSX.Element;
};

const ConditonalWrapper: React.FC<ConditonalWrapperProps> = ({
  condition,
  wrapper,
  children
}) => (condition ? wrapper(children) : children);

export { ConditonalWrapper };

and in use

const Block: React.VoidFunctionComponent = () => (
  <ConditonalWrapper
    condition
    wrapper={(children) => <h1>I am wrapped: {children}</h1>}
  >
    <h1 className="text-red-400">Child Text</h1>
  </ConditonalWrapper>
);
about 4 years ago · Juan Pablo Isaza
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!