Skip to content

Commit 8e7478d

Browse files
authored
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
1 parent 67995b6 commit 8e7478d

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1818
- Improve outside click support ([#1175](https://github.com/tailwindlabs/headlessui/pull/1175))
1919
- Ensure that `appear` works regardless of multiple rerenders ([#1179](https://github.com/tailwindlabs/headlessui/pull/1179))
2020
- Reset Combobox Input when the value gets reset ([#1181](https://github.com/tailwindlabs/headlessui/pull/1181))
21+
- Fix double `beforeEnter` due to SSR ([#1183](https://github.com/tailwindlabs/headlessui/pull/1183))
2122

2223
## [Unreleased - @headlessui/vue]
2324

packages/@headlessui-react/src/components/transitions/transition.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ let TransitionChild = forwardRefWithAs(function TransitionChild<
279279
useIsoMorphicEffect(() => {
280280
let node = container.current
281281
if (!node) return
282+
if (!ready) return
282283
if (skip) return
283284
if (show === prevShow.current) return
284285

@@ -328,6 +329,7 @@ let TransitionChild = forwardRefWithAs(function TransitionChild<
328329
container,
329330
skip,
330331
show,
332+
ready,
331333
enterClasses,
332334
enterFromClasses,
333335
enterToClasses,

0 commit comments

Comments
 (0)