-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why are there no control props for the state management components? #159
Comments
If you want to control your components then you don't need intermediate state. Just pass data directly to them. The idea of this project is the same as regular react state: localizing state management where the state shouldn't be lifted. In all other cases you should always lift your state in parent components. |
However there is a trick. To reset component state (any powerplug component) you may pass another <plug.Input initial={props.receivedFromServerValue} key={props.receivedFromServerValue}>
{input =>
<input {...input.bind} />
}
</plug.Input> |
Yes, I thought about that. But with the possibilities of render prop components, parents which exist for state management are disappearing, at least from my code. And at least in the use case that I tackled it would only increase the amount of code, whithout increasing the readability or any other quality indicator. But I do understand that you want to follow a certain set of principles. It keeps the project cleaner. Thank you for the response! |
I was wondering why components like State, Toggle and Value accept an initial value but don't accept a controling value?
Something like this:
Why do you need that? I used
State
to represent the state of a form, which was initially populated by an object. Next the differrent form components would modify the localState
. And in the end thatState
would be submitted to the remote API. This resulted in an updated object, which then populated the formState
again. BecauseState
does not accept changed props I had to write my own component.My guess was you wanted to skip having to compare states of
State
to make it work. Or is there more to it?The text was updated successfully, but these errors were encountered: