Handling multiple instances of a component with tweaks
See original GitHub issueHey! Love the library 😃
I have multiple instances of a component with a useTweaks
call, say:
const Button = ({ text }: { text: string }) => {
const { color } = useTweaks("Buttons", { color: "blue" });
return <button style={{ backgroundColor: color }}> {text} </button>
}
However, every single instance Button
will add its own color
setting in the tweakpane, whereas my intent was to have them all share the same value.
My question: should I just hoist the useTweaks
call up one level and pass the tweaked value down as a prop (feels kind of meh)? Or is there a nicer solution to this? I tried passing the same presetKey
but they still have different tweakpane inputs.
Here’s a sandbox demonstrating the “issue”: https://codesandbox.io/s/gracious-bas-22vg2?file=/src/App.tsx.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6
Top Results From Across the Web
Handling multiple instances of a component with tweaks #36
Hey! Love the library :) I have multiple instances of a component with a useTweaks call, say: const Button = ({ text }:...
Read more >Coding Militia | Episode 028 - ASP.NET Core: From 0 to overkill
One important scenario to consider, is having multiple instances of each component running in parallel. It's a very important topic to consider, ...
Read more >Placing multiple Instances of a component at once
Solved: Hello everyone, I use a "dump assembly" of assemblies to create cut lists. I throw in multiple copies of each assembly for...
Read more >Top 7 Tweaks and Tricks to Improve React Performance
1. Troubleshooting the redundant rerender · 2. Reducing the rerender by splitting the component · 3. What is instance re-creation and how to...
Read more >java - Multiple components deployed to same application server
In general it's not an issue to have multiple instances of any module ... You can probably tweak the JVM settings to handle...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @Pocket-titan we got pumped and decided to rewrite something from scratch, that fits React and supports your idea out of the box with no major hassle.
You’ll also be able to do:
And get the value. Of course the value will only be initialized once (by the first hooks that gets called).
We’ll try to release something in alpha as soon as it’s usable.
PS: the idea is to store the data structure but flatten. So that the store looks like:
If anybody comes across this and wants to try alphas of the new version, drop me a DM on twitter or an email!