Skip to content

Commit

Permalink
Refactor - remove useEffect
Browse files Browse the repository at this point in the history
  • Loading branch information
felixhabib committed May 9, 2024
1 parent b32c96d commit 4203fc2
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/Playroom/Toolbar/Toolbar.tsx
@@ -1,4 +1,4 @@
import { useContext, useState, useCallback, useEffect } from 'react';
import { useContext, useState, useCallback } from 'react';
import { useTimeoutFn } from 'react-use';
import classnames from 'classnames';
import type { PlayroomProps } from '../Playroom';
Expand Down Expand Up @@ -63,12 +63,6 @@ export default ({ themes: allThemes, widths: allWidths, snippets }: Props) => {
const [lastActivePanel, setLastActivePanel] =
useState<typeof activeToolbarPanel>(undefined);

useEffect(() => {
if (activeToolbarPanel) {
setLastActivePanel(activeToolbarPanel);
}
}, [activeToolbarPanel]);

const hasSnippets = snippets && snippets.length > 0;
const hasFilteredFrames =
visibleThemes.length > 0 || visibleWidths.length > 0;
Expand Down Expand Up @@ -165,6 +159,7 @@ export default ({ themes: allThemes, widths: allWidths, snippets }: Props) => {
classNames={styles.transitionStyles}
mountOnEnter
unmountOnExit
onEnter={() => setLastActivePanel(activeToolbarPanel)}
onExited={() => setLastActivePanel(undefined)}
>
<div className={styles.panel} id="custom-id">
Expand Down

0 comments on commit 4203fc2

Please sign in to comment.