-
Notifications
You must be signed in to change notification settings - Fork 4.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
Don't request the deprecated navigation areas endpoint outside of the Gutenberg plugin #37187
Changes from 1 commit
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 |
---|---|---|
|
@@ -109,12 +109,18 @@ function Navigation( { | |
layout: { justifyContent, orientation = 'horizontal' } = {}, | ||
} = attributes; | ||
|
||
const [ areaMenu, setAreaMenu ] = useEntityProp( | ||
'root', | ||
'navigationArea', | ||
'navigation', | ||
navigationArea | ||
); | ||
let areaMenu, setAreaMenu; | ||
// Navigation areas are deprecated and on their way out. Let's not perform | ||
// the request unless we're in an environment where the endpoint exists. | ||
if ( process.env.GUTENBERG_PHASE === 2 ) { | ||
// eslint-disable-next-line react-hooks/rules-of-hooks | ||
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. I'm not sure it's fine to ignore the rule of hooks. Won't this break other hooks since they need to be accessed in a known order? 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. In this case it's okay because we can guarantee that 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. Yeah, true, I guess that's ok then. |
||
[ areaMenu, setAreaMenu ] = useEntityProp( | ||
'root', | ||
'navigationArea', | ||
'navigation', | ||
navigationArea | ||
); | ||
} | ||
|
||
const navigationAreaMenu = areaMenu === 0 ? undefined : areaMenu; | ||
|
||
|
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 think we should set a default value for
setAreaMenu
, probably a loadashnoop
, otherwise calling it will trigger an error.