-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
State Reducer / Middleware #637
Conversation
payload: FormikErrors<Values>; | ||
}; | ||
|
||
export function reducer<Values>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems simple but not sure I see the utility in it. Looks like it has to run synchronously so not really middleware. The What are some more "real world" use cases for this? Making the library extensible is 👌but I'd worry that this feature might not be prescribing good patterns |
If the goal is effect handling you should go full middleware imo |
Also the more I think about this the more it feels like a state-centric solution in a library that I believe to be component-centric |
With respect to
tbh I hadn't thought about state vs. component approach until you just articulated it so concretely. I agree 100% that formik is and should continue to be component-centric. Making me dislike this code because it mixes the 2 rather poorly. However, the reducer prop and refactoring to a internal reducer don't need to go together. What are your thoughts on using the state reducer internally? This could give us logging and dev tools, but not sacrifice component-centricity. |
If you think it's a better internal API then by all means. I am curious to see a better effect handling story which seems to be at the core of what this is getting at. I see in the discussion that a few ideas have been explored. Things I'd consider:
Are there other use cases or effect handling stories that I've missed? |
Agree with all three points. |
Going to close for now. |
This is proof of concept state reducer. I didn't quite finish exposing all state changes (still have to do submit and reset). Anyways, I thought it was enough to get some feedback. I tried to keep things elm like. This whole thing would be soooo much easier with pattern matching, but i digress. Here is my state reducer attempt.
Related: #401