Expose Panel and useLocalStorageState

Summary: Expose a Panel api from Sandy, which is quite similar to the old one, except that it uses Antd, and it will remember the users closed / open preference through sessions, a much requested feature.

Reviewed By: nikoant

Differential Revision: D27966607

fbshipit-source-id: 9b18df377215c1e6c5844d0bf972058c8c574cbb
This commit is contained in:
Michel Weststrate
2021-04-23 09:28:45 -07:00
committed by Facebook GitHub Bot
parent faf8588097
commit c005753018
12 changed files with 135 additions and 27 deletions

View File

@@ -57,6 +57,14 @@ export function TrackingScope({
);
}
/**
* Gives the name of the current scope that is currently rendering.
* Typically the current plugin id, but can be further refined by using TrackingScopes
*/
export function useCurrentScopeName(): string {
return useContext(TrackingScopeContext);
}
export function Tracked({
events = 'onClick',
children,
@@ -73,7 +81,7 @@ export function Tracked({
action?: string;
children: React.ReactNode;
}): React.ReactElement {
const scope = useContext(TrackingScopeContext);
const scope = useCurrentScopeName();
return Children.map(children, (child: any) => {
if (!child || typeof child !== 'object') {
return child;