You can treat an entity just like a variable. Just declare as many entities as you want. Don't think of an entity as a class that you need to "instantiate".
For example:
exportconstcounterA=entity(0)exportconstcounterB=entity(0)exportconstcounterC=entity(0)// and so on...
And if you want to avoid declaring many actions that all look the same, you can do something like this:
What happens if you need multiple instances of entity?
You can treat an entity just like a variable. Just declare as many entities as you want. Don't think of an entity as a class that you need to "instantiate".
For example:
And if you want to avoid declaring many actions that all look the same, you can do something like this:
This library is flexible. You can do it however you prefer.
It's a very useful thought though - as every variable needs to instantiated with initial state. If it's class or not doesn't matter at all.
What I see here in your examples is completely no different of just using
useState()
. Thus I completely miss the point that you're trying to achieve.Your example would not be "shared state", is it?