-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[Core] Remove isMounted() #3437
Conversation
In my opinion, we should go on and remove the check! as it is an anti pattern to hold a reference to an unmounted component. So an explicit error is more appropriate than a silent undefined return, in my opinion. But let's see what others think too 😅 |
I don't disagree that it'd be nice to remove the check. I suppose I'm not completely sure why the check is there in the first place, so my gut was to keep it. But I'd be curious to hear if anyone has any idea about that.
In this implementation, according to the React documentation, we won't be holding a reference to the unmounted component because the callback is called with null when the component unmounts: From the docs:
Whether or not we do the check for the events, I think we should still (at some point) replace the string ref with a callback ref since it looks like React will be deprecating the string ref. |
I meant the users of TextField. if they call getValue on an unmounted TextField they should get error instead of a silent undefined.
True, but even better than that is to have no |
Oh I understand. I agree. I suppose another reason why they exist now is because of the
I'd love to have no refs. Not sure if we're ready to tackle that yet but I'm all for that too 😄 |
Well I think this is good to go for now 👍 |
🚀 😆 Thanks for the feedback @alitaheri! |
Thanks for taking the lead on this 👍 |
I completely agree. |
I was kinda scared of that too 👍 I agree with you |
eafda4b
to
eabd8b9
Compare
Can I get feedback on this? 😁 Honestly, I'm really confused with how the timeouts are being used in a lot of these cases. 😄 I'm also not quite sure how to reproduce the original issue that caused us to implement the |
@@ -70,7 +78,7 @@ const TransitionItem = React.createClass({ | |||
}); | |||
|
|||
setTimeout(() => { |
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.
I think we can use cancellation for this.
this.timer = setTimeout(callback, 450);
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.
Woops, I thought I came back to fix that. I must've forgotten or lost it. Thanks!
Squashed commits: [06a5da6] Fix for dialog
Squashed commits: [6677673] Removed underscore in timeout member in popover
eabd8b9
to
db35e80
Compare
Looking at this again I wasn't always consistent with the names of the timers/timeouts. Maybe I should fix that, maybe it's not critical though. |
It looks good, in my opinion. No need to be picky right now. 😁 👍 👍 Great job @newoga 😍 Also, cool git history you built there 😎 |
Great, thanks @alitaheri! If we want to squash them all down still that's fine too! I was just trying to be extra clear with the commits since I'm unfamiliar these timeouts. |
No I think we should keep them. the whole point of squash is to have a clean and self documenting history. These sets of commits do exactly that! So we should keep it as is 👍 Also, I don't see any smelly piece of change. It's very unlikely you've broken anything 😁 |
Awesome, sounds good to me! 😄 |
@newoga One more eslint rule enforced 😍. |
@oliviertassinari I'm all good with how it is right now. feel free to merge after you review 👍 😍 |
[Core] Remove isMounted()
@newoga Thanks for taking care of this 👍! |
Resolves #2573