File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -421,6 +421,9 @@ export interface TransitionHookReturnValue<E extends HTMLElement>
421421 * @example
422422 * Simple Example
423423 * ```tsx
424+ * import { ReactElement, useEffect, useRef } from "react";
425+ * import { useCSSTransition } from "@react-md/transition";
426+ * import { useRouter } from "react-router-dom";
424427 *
425428 * function Example(): ReactElement {
426429 * const { pathname } = useRouter();
@@ -430,11 +433,15 @@ export interface TransitionHookReturnValue<E extends HTMLElement>
430433 * classNames: "some-enter-transition",
431434 * });
432435 *
433- * const prevPathname = useRef(pathname);
434- * if (pathname !== prevPathname.current) {
436+ * useEffect(() => {
437+ * // Do not trigger transition on first load.
438+ * if (prevPathname.current === pathname) {
439+ * return;
440+ * }
441+ *
435442 * prevPathname.current = pathname;
436443 * transitionTo("enter");
437- * }
444+ * }, [pathname, transitionTo]);
438445 *
439446 * return <div {...elementProps}>{content}</div>;
440447 * }
You can’t perform that action at this time.
0 commit comments