reflex icon indicating copy to clipboard operation
reflex copied to clipboard

Better (or more clearly documented) ways to have component states

Open mwesterhof opened this issue 1 year ago β€’ 3 comments

I've had a great time playing around with pynecone, and it seems very promising.

One thing that trips me up though, i've been trying to create components in a project that are aware of their own states, somewhat similar to how you could simply use the "useState" hook in any isolated react component. So far, I haven't found a way to make this work properly. I find myself passing the app state as a parameter to whatever component function I'm calling, and managing absolutely everything in the central state.

Now, the documentation mentions substates, but there seem to be 2 issues with that;

  1. a lack of clarity about real life applications, and nothing informative in the pynecone examples either
  2. they seem to rely on subclassing the root state, apparently. If i want an isolated component to manage its own state (and define it in a separate module), that doesn't seem very viable. Is there a way for an imported component to manage its own isolated state? If so, it would be worth showing in the documentation, i think

mwesterhof avatar Dec 20 '22 09:12 mwesterhof