-
Notifications
You must be signed in to change notification settings - Fork 157
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
Follow react rules of hooks #1228
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -153,24 +153,34 @@ const DistributorIcon = () => ( | |||||
* Add the Distributor panel to Gutenberg | ||||||
*/ | ||||||
const DistributorPlugin = () => { | ||||||
// Ensure the user has proper permissions | ||||||
if ( | ||||||
dtGutenberg.noPermissions && | ||||||
1 === parseInt( dtGutenberg.noPermissions ) | ||||||
) { | ||||||
return null; | ||||||
} | ||||||
|
||||||
// eslint-disable-next-line no-shadow, react-hooks/rules-of-hooks -- permission checks are needed. | ||||||
const postType = useSelect( ( select ) => | ||||||
select( 'core/editor' ).getCurrentPostType() | ||||||
); | ||||||
|
||||||
// eslint-disable-next-line no-shadow, react-hooks/rules-of-hooks -- permission checks are needed. | ||||||
// eslint-disable-next-line no-shadow -- permission checks are needed. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
const postStatus = useSelect( ( select ) => | ||||||
select( 'core/editor' ).getCurrentPostAttribute( 'status' ) | ||||||
); | ||||||
|
||||||
// eslint-disable-next-line @wordpress/no-unused-vars-before-return | ||||||
const distributorTopMenu = document.querySelector( | ||||||
'#wp-admin-bar-distributor' | ||||||
); | ||||||
|
||||||
// eslint-disable-next-line no-shadow -- permission checks are needed. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
const post = useSelect( ( select ) => | ||||||
select( 'core/editor' ).getCurrentPost() | ||||||
); | ||||||
|
||||||
// Ensure the user has proper permissions | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. May as well fix the comment style while we're changing this code.
Suggested change
|
||||||
if ( | ||||||
dtGutenberg.noPermissions && | ||||||
1 === parseInt( dtGutenberg.noPermissions ) | ||||||
) { | ||||||
return null; | ||||||
} | ||||||
|
||||||
// Ensure we are on a supported post type | ||||||
if ( | ||||||
dtGutenberg.supportedPostTypes && | ||||||
|
@@ -179,14 +189,6 @@ const DistributorPlugin = () => { | |||||
return null; | ||||||
} | ||||||
|
||||||
const distributorTopMenu = document.querySelector( | ||||||
'#wp-admin-bar-distributor' | ||||||
); | ||||||
|
||||||
// eslint-disable-next-line no-shadow, react-hooks/rules-of-hooks -- permission checks are needed. | ||||||
const post = useSelect( ( select ) => | ||||||
select( 'core/editor' ).getCurrentPost() | ||||||
); | ||||||
// Make the post title and status available to the top menu. | ||||||
dt.postTitle = post.title; | ||||||
dt.postStatus = post.status; | ||||||
|
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.