Group app wide ui state into one object

Summary: Should be a bit easier to see what UI state we are holding at the plugin instance level

Reviewed By: lblasa

Differential Revision: D41498272

fbshipit-source-id: 6d88086766efd9c39f71be7e2ce32c5058494c96
This commit is contained in:
Luke De Feo
2022-11-24 09:23:16 -08:00
committed by Facebook GitHub Bot
parent 7fc64adfd4
commit 6bb541a33f
5 changed files with 52 additions and 50 deletions

View File

@@ -24,7 +24,7 @@ export const UIDebuggerMenuItem: React.FC<{
}> = ({text, onClick}) => {
const instance = usePlugin(plugin);
const isMenuOpen = useValue(instance.isContextMenuOpen);
const isMenuOpen = useValue(instance.uiState.isContextMenuOpen);
/**
* The menu is not a controlled component and seems to be a bit slow to close when user clicks on it.
* React may rerender the menu before it has time to close resulting in seeing an incorrect context menu for a frame.
@@ -37,7 +37,7 @@ export const UIDebuggerMenuItem: React.FC<{
<Menu.Item
onClick={() => {
onClick();
instance.isContextMenuOpen.set(false);
instance.uiState.isContextMenuOpen.set(false);
}}>
{text}
</Menu.Item>