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

143
Views
react-icons set size prop of Icon in child

What I would like to do but isn't possible is something like this:

import { FaBook } from 'react-icons/fa';

const Parent = () => <Child icon={FaBook}>Save</Child>;

Then in the child

const Child = ({ icon }) => (
  <div>
    <Icon as={icon} size={20} />
    <Icon as={icon} size={30} />
  </div>
);

This is so I don't have to pass an iconSmall and iconLarge prop separately the size is the only differentiator. I there a react way I can add the size property on the child?

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

Whatever the Icon component is. Something like this?

Parent.js

import React from 'react';
import {FaBook} from 'react-icons/fa';
import Child from './Child';

const Parent = () => <Child icon={FaBook}>Save</Child>;

export default Parent;

Child.js

import React from 'react';

const Child = ({icon}) => (
    <div>
        {icon({size: 20})}
        {icon({size: 30})}
    </div>
);

export default Child;
about 4 years ago · Santiago Gelvez 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!