Prevent withSidebarNotices
breaking the rules of hooks
#8820
Conversation
The release ZIP for this PR is accessible via:
Script Dependencies ReportThere is no changed script dependency between this branch and trunk. This comment was automatically generated by the TypeScript Errors Report
🎉 🎉 This PR does not introduce new TS errors. |
Size Change: -12 B (0%) Total Size: 1.06 MB
ℹ️ View Unchanged
|
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.
Thank you for fixing it so quickly! Works great! 🎉
Just for my learning, from now onwards we should first declare everything before returning out?
@tarunvijwani no, you don't have to declare everything. You just cannot use hooks (useEffect, useState, etc) after a return statement. |
Fixes the following console warning:
This is because we are breaking the rules of hooks by returning before they have been executed.
Steps to reproduce:
Testing
Repeat the above steps and ensure the console is free of warnings.
Changelog