Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

288
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda