Strange issue at hand. The progress bar in question appears like this:
1 export default function PercentageBar(props) {
2 return (
3 <div className="w-full h-1 my-1 bg-stone-200">
4 <div className={`h-1 bg-orange-500 w-[${props.percent}%]`} />
5 </div>
6 );
7 }
The styling is achieved using Tailwind CSS. To explain for those unfamiliar, the outer div spans the full width of the parent div, has a height of 1, top and bottom margin of 1, and is colored in a grayish hue. The inner div is then layered on top, also with a height of 1. The inner div is in orange and spans the width of props.percent
(a percentage of the parent div's total width).
I have confirmed that props.percent
is correctly passed in.
However, when props.percent
dynamically changes during runtime, line 4 behaves strangely at times (irrespective of the specific percent value).
For instance, if props.percent
was initially 48 and later becomes 52, Inspect Element shows:
<div className={`h-1 bg-orange-500 w-[52%]`} />
which is accurate. Yet, it renders as follows (a full bar)
<div className={`h-1 bg-orange-500 w-[100%]`} />
Moreover, there are instances where it renders as if props.percent
is 0, post a change in the percent value. This issue persists regardless of attempts like hard refreshes, cache resets, etc., occurring sporadically and across various browsers. Sometimes the problem doesn't surface with repeated refreshing. Any insight into what might be occurring here? Much obliged!