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

193
Visualizações
preact - how to get the current component instance

Is there a way to access the instance / get a reference of the function Component that it is currently rendered/active in preact, an thus its current props, hooks, internal state, effects etc.?

I am looking for something like React's __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner (but consumable also in production) or Svelte's runtime internal get_current_component().

To give you a bit of context, the reason why I need it is because I am building a library that provides a function that should be able to access the props of the Component currently consuming this function, in production and during runtime.

I was looking at preact's source code, and I found that in preact/hooks/src/index.js there is a currentComponent global variable, but I couldn't understand how this is obteined. I have tried to play with options, or with render, imported from preact, but still couldn't figure out how to access the current component.

Is there any way to achieve it in preact, or is there any 'hack' to achieve something similar?

Thx in advance

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