-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Fix switching Priority Mode with an active draft message from crashing app #7907
Merged
Merged
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b9199e1
fix crash
ctkochan22 f3e59cb
always reorder when changing focus
ctkochan22 89eb09c
fix fix
ctkochan22 b88a9fa
add comments because it took me several tries
ctkochan22 da4dc8a
revert removing reorder condition
ctkochan22 edb7149
clean it up a bit
ctkochan22 d69f3bd
factor in priorityMode switching
ctkochan22 208d137
Merge branch 'main' into ckt_focus_fixDraft
ctkochan22 28d0309
fix comment
ctkochan22 88ea587
clarify
ctkochan22 c9fcea4
clarify comment
ctkochan22 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can we compare
this.props.priorityMode
withnextProps.priorityMode
and leavestate
out of the equation entirely?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.
this.props isn't available within
getDerivedStateFromProps
for some reason.Out of curiosity, why do you want to leave state out of the equation? Bc we are not using
state.priorityMode
anywhere else?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.
That, and we're just setting whatever is in props directly to state which usually means it does not need to be there. If we need to track the updates of a prop then we can just look at the prop.
Anyway, I think we are basically stuck at this point and would need to refactor the entire component to fix this. I'm remembering now that this is a static method and can't access the component instance at all.
There are some good explanations here that go into why we should not use this here (but hopefully the explanation I just gave also makes sense).
https://reactjs.org/blog/2018/06/07/you-probably-dont-need-derived-state.html
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 would actually be super interested in refactoring the entire component
However, should I scale back some of the changes then to get somethign merged now? Right now the undefineds are causing a crash, or requires a hard refresh
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.
Yeah! I created this issue here - feel free to steal it from me.
But agree we should just fix this for now :D