Is there a way to define the position of a div using runtime data? Would setting the className string through some hook be the solution? I often encounter issues with asynchronous operations causing this type of problem.
I was hoping someone could guide me in the right direction, as it's possible that what I'm trying to achieve is not compatible with tailwind CSS:
{timeRecord.clockedTimes.map((time, index) => {
let date = new Date(time.start);
let topOffset = getTopOffset(date).toFixed(4);
let stringOffset = `top-[${topOffset}%]`;
let className = "absolute " +stringOffset+" outline outline-red-400 w-1/2 left-1/2";
return (
<div className={className} >
{stringOffset}
</div>
)
})}
If I extract the text displayed inside the div by rendering the stringOffset from within and eliminate the construction of the className to make it a static string with the runtime data copied and pasted, it positions correctly.