-
Notifications
You must be signed in to change notification settings - Fork 28
Feature Request: could setState mirror react.setState functionality? #49
Comments
Sounds reasonable. Let me see if I can do it in the next few days. |
Hi @njsaeli for now, please use a store with a reducer to achieve the desired goal, it's actually not that simple to mimic the react API |
@jhonnymichel @njsaeli I have been working on an alternative for react-hookstore that fits my clients needs a bit better. Feel free to check it out. |
That's very cool. A lot of decisions I wish I made for react-bookstore. the truth is I made this project in very early hooks days and that's why it got attention, but I personally never used it in big projects and that's why there are a lot of design flaws because I never felt the pain they caused. But it's nice to see that the project inspired improved solutions like yours. I'm specially curious about the last bit: how the inverse subscription order can guard against noop errors. Gonna take a close look to that 👍 |
@jhonnymichel Regarding the subscription order, here is a simple example: With the inverse order we dont get the noop, because the deeper the child, the earlier it gets the rerender, and the parents that can conditionally not render them (or change router route) get a rerender after them. |
Unless I am mistaken,
Currently React.setState will accept either the new state or a function which accepts the old state and return the the new state, while the react-hookstore version of setState will only accept the new state, as well as having the optional callback.
could the react-hookstore version be adjusted to allow for the function to be accepted in place of the state value?
Based on what I've looked at in the source code, the only thing preventing this from working seems to just be a typing issue? Unless i'm missing something I believe hookstore is using the react.setState everywhere under the hood.
The text was updated successfully, but these errors were encountered: