css transition fails on Chrome #13471
Unanswered
aquaductape
asked this question in
Help
Replies: 1 comment
-
Ok, I solved it. I needed to wrap the condition that returns a component inside an element. In this snippit I used a div. return (
<div className="App">
<MainProgressBar
total={list.length}
currentIdx={currentIdx}
></MainProgressBar>
<div>
{!isFinished ? (
<Primary onNext={onNext}></Primary>
) : (
<Secondary></Secondary>
)}
</div>
</div>
); However I don't understand why that solves the transition problem. I know it's a NextJS issue because I placed the same code in Create React App framework, and transition didn't have any issues. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Here's the codesandbox demo
This issue happens in Chrome.
Here's the structure. In my index file under pages directory, the parent renders
MainProgressBar
, and eitherPrimary
orSecondary
based on whether the progress is finished or not.I have button that is belongs to
Primary
. When that button is clicked the current index of a generic list is increased by one. The length of the ProgressBar is based on current index divided by the length of the list.For example
currentIdx -> 3
list.length -> 4
would basically be3 / 4
which the ProgressBar length will be 75%.When the ProgressBar increases, there's a 1300ms transition based on a css transition property. Once the currentIdx matches the length, then isFinished state is updated, which results in
Secondary
to render instead ofPrimary
, and that's when the transition fails. TheProgressBar
reaches the remaining 100% length immediately with no transition.One workaround is placing the button as a direct child in the parent component, then transition works even when isFinished is updated.
But I would rather not do that, since on my main project, it's structured that way.
Here's the codesandbox demo
Beta Was this translation helpful? Give feedback.
All reactions