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

286
Views
A function to unify different types of react artifacts

We are creating a base library for administration panel (something similar to react-admin).

However, in react world, objects can be of a lot of types. There is no single consistency.

Let's say you have a component called Action, and your library user should provide a list of it for you.

These are possible things that you might get:

// a single item, as a JSX variable
const Actions = <Action />

// an array of items, as a JSX variable
const Actions = <>
   <Action />
   <Action />
</>

// an arrow function, but returning a single JSX result
const Actions = (params) => <Action />

// an arrow function, but returning an array of JSX results
const Actions = (params) => <>
    <Action />
    <Action />
</>

// an arrow function, having body, returning a single JSX result
const Actions = (params) => {
    return <Action />
}

// an arrow function, having body, returning an array of JSX results
const Actions = (params) => {
    return <>
         <Action />
         <Action />
    </>
}

// or they might give lowercase variables, etc.

And there might be other possible ways that I don't know.

This makes wring code very frustrating and difficult. Because for simple JSX variable you should use interpolation syntax ({actions}), for function components you should render using <Actions />, etc.

Is there a function in react which we can use to wrap all of these types in an empty fragment and unify them?

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!