From 8e7478d1d2e658ce93b490d7e22b22e43201a43e Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Wed, 2 Mar 2022 16:30:17 +0100 Subject: [PATCH] Fix double `beforeEnter` due to SSR (#1183) * prevent initial transitioning in SSR environment Due to SSR and the hydration step, the transition code was already called even if we were not ready yet. This caused an issue where the `beforeEnter` callback got fired twice intead of once. Fixes: #311 * update changelog --- CHANGELOG.md | 1 + .../@headlessui-react/src/components/transitions/transition.tsx | 2 ++ 2 files changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c522f7..50af462 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Improve outside click support ([#1175](https://github.com/tailwindlabs/headlessui/pull/1175)) - Ensure that `appear` works regardless of multiple rerenders ([#1179](https://github.com/tailwindlabs/headlessui/pull/1179)) - Reset Combobox Input when the value gets reset ([#1181](https://github.com/tailwindlabs/headlessui/pull/1181)) +- Fix double `beforeEnter` due to SSR ([#1183](https://github.com/tailwindlabs/headlessui/pull/1183)) ## [Unreleased - @headlessui/vue] diff --git a/packages/@headlessui-react/src/components/transitions/transition.tsx b/packages/@headlessui-react/src/components/transitions/transition.tsx index d13dc79..ce83116 100644 --- a/packages/@headlessui-react/src/components/transitions/transition.tsx +++ b/packages/@headlessui-react/src/components/transitions/transition.tsx @@ -279,6 +279,7 @@ let TransitionChild = forwardRefWithAs(function TransitionChild< useIsoMorphicEffect(() => { let node = container.current if (!node) return + if (!ready) return if (skip) return if (show === prevShow.current) return @@ -328,6 +329,7 @@ let TransitionChild = forwardRefWithAs(function TransitionChild< container, skip, show, + ready, enterClasses, enterFromClasses, enterToClasses,