Fixed visibility updating announcement bar in AdminX (#18058)

no issue

- fixed an issue where toggling the visibility of the announcement bar doesn't update the preview.
---

<!-- Leave the line below if you'd like GitHub Copilot to generate a
summary from your commit -->
<!--
copilot:summary
-->
### <samp>🤖 Generated by Copilot at bad7a08</samp>

Simplified the `AnnouncementBarPreview` component by using a shallow
equality check for the `visibility` prop. This is part of a refactor to
use React hooks and functional components.
This commit is contained in:
Ronald Langeveld 2023-09-11 16:14:09 +07:00 committed by GitHub
parent 210de7fa11
commit 3755384b66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -96,18 +96,10 @@ export default memo(AnnouncementBarPreview, (prevProps, nextProps) => {
} }
// Check if visibility array changed in size or content // Check if visibility array changed in size or content
if (prevProps.visibility?.length !== nextProps.visibility?.length) { if (prevProps.visibility !== nextProps.visibility) {
return false; return false;
} }
if (prevProps.visibility && nextProps.visibility) {
for (let i = 0; i < prevProps.visibility.length; i++) {
if (prevProps.visibility[i] !== nextProps.visibility[i]) {
return false;
}
}
}
// If we've reached this point, all props are the same // If we've reached this point, all props are the same
return true; return true;
}); });