Weird problem here. I have a progress bar that looks 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 done via Tailwind CSS. If you're unfamiliar, basically what's happening is the outer div is as wide as the parent div, has a height of 1, margin on the top and bottom of 1, and is colored in a gray-ish tone. The inner div is then rendered on top of that, which also has a height of 1. The inner div is in orange and is as wide as props.percent (a percentage of the full width of the parent div).
I've verified that the props.percent is being passed in properly.
When props.percent changes at runtime dynamically, line 4 in particular sometimes acts weird (regardless of the percent passed in).
For example, if props.percent was equal to 48 and is now equal to 52, Inspect Element tells me that the line is
<div className={`h-1 bg-orange-500 w-[52%]`} />
which is correct. However, it's rendered like below (a full bar)
<div className={`h-1 bg-orange-500 w-[100%]`} />
Furthermore, sometimes it's rendered like props.percent equals 0. This only happens after props.percent changed values.
I've tried doing hard refreshes, resetting caches, etc. but the problem persists sporadically and across different browsers. If I refresh enough, sometimes the problem doesn't appear. Any idea what's happening here? Much appreciated!