How to use this for multiple components?
Thank you for this project, I absolutely love the simplicity of hook-based knobs! I would like to be able to use this to debug different components simultaneously. I tried first by naively attaching a non-portal Inspector to each component I want to inspect but then found that hooks begin to mix between them.
Is this usage supported, in the roadmap or intended at all?
Hey,
Can you please create a codesandbox example with the issue and share it here?
Hi, sorry for the delayed response. Hopefully the following sandbox will help illustrate what I'm trying to achieve:
~https://codesandbox.io/embed/condescending-wave-1knrl~ (:point_left: had an implementation error :no_good_man: )
Edited link: https://codesandbox.io/s/hopeful-fire-c3goe
Essentially I want to have two (read: any number of) independently running inspectors, so that I can look at different components at the same time, each in their isolated Retoggle context.
I did not expect the example above to work, because as far as I can see there's no discernable way that <Inspector /> could possibly know what environment it lives in.
I wonder if a simple syntactic extension of some nature like the following would work:
const retoggleContext = useRetoggle();
// then either something like this
// (but it may be a breaking change depending on the argument positioning)...
const booleanKnob = useBooleanKnob("My Boolean Knob", false, retoggleContext);
// ...or something like this
const booleanKnob = retoggleContext.use(useBooleanKnob, "My Boolean Knob", false);
// ... then later
<retoggleContext.Inspector />
You are right. With the current design, the Inspector doesn't really know much about the toggles. We could agree on an API to support multi inspectors. But unfortunately, I don't have time to work on this soon!
@soul-codes FYI support for multiple inspectors is now supported with version 1.0.0. You can find documentation on it here. I know it's been a while since you were looking for this, but I think the changes in 1.0.0 should support what you are describing.