question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Conditionally rendered children components not staggering

See original GitHub issue

1. Describe the bug

Children components wrapped in AnimatePresence don’t stagger as they should if they are not rendered initially. In provided example, you can see a comparison between child components mapped initially from static data array (works fine) and rendered conditionally, e.g. after some remote data is fetched, which is a common scenario.

2. CodeSandbox reproduction of the bug https://codesandbox.io/s/staggerchildrenissue-tkkie?file=/src/App.js

3. Steps to reproduce Refresh provided codesandbox example.

4. Expected behavior Children components rendered conditionally should be staggered the same as the ones rendering initially.

5. Environment details KDE neon 5.19, Chrome 85.0.4183.102 (Official Build) (64-bit)

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:4
  • Comments:6

github_iconTop GitHub Comments

1reaction
snehasis8commented, Aug 26, 2022

It makes no sense if it’s not able to perform on the dynamic data.

0reactions
TimoPcommented, Sep 20, 2022

Edit: Inspired by @mattgperry’s comment above, I figured out the following workaround – by setting a key on the parent element to the length of the dynamic data, something like this:

Yes but that only helps if the parent did not have their own transitions. A key change would reset this transition.

The use of this feature is limited if it did not work if children get added after the parent transition start.

I have made a small Sandbox for demonstration for my ticket: Example Toggle Demo1: Expected behavior Toggle Demo2: Example with children added after timeout

Read more comments on GitHub >

github_iconTop Results From Across the Web

Child component not re-rendering when parent re ... - Reddit
In the counter component, I am rendering button which changes the state of counter component and also rendering Logger component. I am not...
Read more >
conditional rendering is not happening to display child ...
I am trying to render conditionally to display child component. But it is not happening. on button click i am getting the values,...
Read more >
Staggering components on enter with react css transition group
I looked at this question but would like to try do it using the react transitions group.
Read more >
Props and Conditional Rendering - DEV Community ‍ ‍
The unidirectional data flow concept simply means that data can only be passed from the parent to the child component and not the...
Read more >
Conditional React Context: Treating Each Consumer Differently
Here's the mount profile where everything is rendered. We add an Indirection component in the middle to hold the following two consumers Child...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found