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

220
Visualizações
How to get size/bounding rect of arbitrary jsx?

I am currently trying to get the dimensions / bounding rect of some jsx I return from a function. Every post I've seen online says to create a ref and use element.current.getBoundingRect(). However, I cannot do this with my code as I am using a function to dynamically build this jsx and put it into an object rather than making full react components.

Is there any way I can do this? Or is this not possible?

The only thing I can thing of is maybe dynamically creating a new full functional component in my .forEach instead of just creating jsx in a fragment, but when I tried that it still didn't work as I had no way to access the ref after.

EDIT: Here's how I'm making my jsx

export const createNodeTypes = (data) => {
  const nodesList = {};
  if (data) {
    data.forEach(({ node }) => {
        const newNode = () => (
          <>
            <div>
              <[insert other jsx here]>
            </div>
          </>
        );
        nodesList[node.name] = newNode;
      });
  }
  return nodesList;
};

It's worth noting the reason I'm doing it this way is for creating a nodeTypes object like react-flow-renderer is expecting for custom node types

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