fix: add defensive optional chaining to CommentScreen to prevent crashes on missing params (Issue #2063)#2089
Conversation
…ke notifications (Issue SB2318#2063)
|
Thank you @, for creating the PR and contributing to our UltimateHealth project 💗. |
Automated Review FeedbackProvide actionable comments grouped by severity: ImportantThe change Consider adding a more robust check to ensure a valid if (article?._id && article?.authorId && article?.pb_recordId) {
navigation.navigate('ArticleScreen', {
articleId: Number(article._id),
authorId: article.authorId.toString(),
recordId: article.pb_recordId,
});
} else {
// Handle the case where article details are missing, e.g., show a toast or log an error.
console.warn('Cannot navigate to ArticleScreen: Missing article details.');
}
|
PR Description
This PR adds defensive optional chaining to
CommentScreen.tsxto prevent the application from experiencing a hard-crash when route parameters (likearticle) are malformed orundefined. This resolves the underlying fatal error reported in Issue #2063 when navigating fromArticleCommentLikenotifications. While the routing omission inNotificationScreenwas recently patched upstream, these UI safeguards ensure the screen is permanently bulletproof against any future routing parameter anomalies.Type of Change
Select your work-area
Related Issue
#2063
Add your Work Example
📷 Add a Snapshot
N/A - This is a programmatic safeguard fix, no visual UI changes were made.
Fixes (mention the issue number which this fixes)
Closes #2063
Checklist
Undertaking
My code follows the style guidelines of this project.
I have performed a self-review of my code.
I have commented my code, particularly in hard-to-understand areas.
I have made corresponding changes to the documentation.
I have checked for plagiarism and assure its authenticity.
I have read and followed the code of conduct for this repository. I understand that violation of this undertaking may have legal consequences.
I Agree