-
-
Notifications
You must be signed in to change notification settings - Fork 102
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
Component should have two "modes", controlled and uncontrolled, just like text inputs #49
Comments
@cbothner Could you expand a little more on what you mean by this sentence/phrase?
What I'm understanding (correctly or incorrectly) from your analysis is that if |
I'm going to get started on this this weekend and not let it linger. |
Sorry for the delay on this. Yes, that is what I mean. That’s exactly what happens with
|
Getting started on this. |
Edit: This is gonna take a while... lots to change. I'll definitely need some review on this when I get something workable |
One other thought: display the warning, definitely, but I think it’s okay to leave the behavior undefined if this does happen. When I have seen that error for inputs in React (due to accidentally passing I would imagine it could work out in perhaps the most common case that is likely to come up. Transitioning from |
@cbothner What do you think of this concept? Because there are a lot of |
...following the previous comment: I reckon that the controlled component might not even need to manage any of its own state, since it receives that state via the props, unless there are some weird timing issues that require it |
Doesn’t the animation throw a wrench in “no internal state?” I just spent a few minutes looking through React’s code for input elements to learn from how they do it. When it’s controlled, they force the DOM node value to the prop value with every update, if it’s not already right. When I imagine this: ImageZoom component has only the internal state Zoom component is the portal; handles animation and the loading of a high res image but has no internal state about whether or not it should be visible. (Animation in React is not my forte, so I’ll defer to you for the details here) This way, I don’t think you need any logic for “if isZoomed was passed on mount” or anything. The Zoom component always has a value for its prop isZoomed, so it will always do the right thing. And then for the ImageZoom component, you can throw an error on Does any of that make sense? |
Okay I'll take a few stabs at this over this week and see where we end up. Pretty slammed at present, but will see what I can do. |
Sorry y'all, haven't had any time to devote to this. Sigh. If anybody else wants to take a stab at it, by all means take it over; otherwise, I'm hoping for having time in the next couple of days. |
Good news! I'll be spending a good chunk of a day next week fixing this issue and making a couple of other changes. |
This should now be addressed in version |
Issue stems from the discussion and initial issue on #48.
Initial Issue:
Diagnosis & Solution Plan
Further thoughts
TBD
The text was updated successfully, but these errors were encountered: