Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

295
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda