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

398
Visualizações
SolidJS - how to get the current component instance

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

I am looking for something like React's __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIREDReactCurrentOwner (but consumable also in production) or Svelte's runtime internal get_current_component(). To give 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.

I have tried to play around with SolidJS getOwner(), but I am not sure I understood it. I cannot find any reference to the Component's current props or signals or effects.

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

Thx in advance

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Because of how Solid works and handles "components", those sorts of things are limited, unavailable, or available only in development. In production Solid throws out what it doesn't need to work.

The problem is that "component instances" don't exist in solid per se, unlike Svelte or React. It's just a graph of signals and reactions. What is a component? Just a function that returns some DOM elements, creates some signals and computations by adding them to the graph, and then well... it gets garbage collected and that's it. A component in production is no different than any other function (hook).

Of course, that graph is still analyzable to some extent. (a bit less in production) You can see all the computations (createEffect, createMemo, etc.) and signals they currently observe. Not much more than that. Maybe context too. Props as we understand it — a reactive object passed by the parent to child — is just an object with some getters passed to a function — it doesn't exist in the reactive graph as a separate entity. You can still get access to the signals within — but only if they are used in some effects — some node of the creative graph has a reference to it.

Kinda like this: https://playground.solidjs.com/?hash=597826062&version=1.4.1

So, if you are creating a library that is meant to be used in production — I would rather advise you to have the data you want to be provided explicitly with arguments/props rather than by walking the internals.

But if you are looking to make some visualizations of the reactive graph during development, you can see the source code of this debugger: https://github.com/thetarnav/solid-devtools/tree/main/packages/debugger

about 4 years ago · Juan Pablo Isaza Relatório
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