Skip to content

Commit

Permalink
chore: adding nodeRef, then dont need to ReactDOM.findDOMNode
Browse files Browse the repository at this point in the history
  • Loading branch information
vctqs1 committed Feb 15, 2025
1 parent 7f69be0 commit 1daa6bd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Playroom/Toolbar/Toolbar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContext, useState, useCallback, useEffect } from 'react';
import { useRef, useContext, useState, useCallback, useEffect } from 'react';
import { useTimeoutFn } from 'react-use';
import classnames from 'classnames';
import type { PlayroomProps } from '../Playroom';
Expand Down Expand Up @@ -40,6 +40,7 @@ export default ({ themes: allThemes, widths: allWidths, snippets }: Props) => {
] = useContext(StoreContext);
const [copying, setCopying] = useState(false);
const [isReady, cancel, reset] = useTimeoutFn(() => setCopying(false), 3000);
const nodeRef = useRef(null);

const copyHandler = useCallback(() => {
dispatch({
Expand Down Expand Up @@ -157,13 +158,14 @@ export default ({ themes: allThemes, widths: allWidths, snippets }: Props) => {
</div>
<CSSTransition
in={isOpen}
nodeRef={nodeRef}
timeout={ANIMATION_TIMEOUT}
classNames={styles.transitionStyles}
mountOnEnter
unmountOnExit
onExited={() => setLastActivePanel(undefined)}
>
<div className={styles.panel} id="custom-id">
<div ref={nodeRef} className={styles.panel} id="custom-id">
{lastActivePanel === 'snippets' && (
<Snippets
isOpen={isOpen}
Expand Down

0 comments on commit 1daa6bd

Please sign in to comment.