useEffect style
I was able to modify the width of a stubborn react-admin component dynamically, using another DOM element as a reference point, and it was actually pretty clean! Here’s a stripped-down version:
MyComponent = () => {
[width, setWidth] = useState()
useEffect(() => {
const main = document.querySelector('main');
if (!main) {
return;
}
setWidth(main.getBoundingClientRect().width - 50);
});
render <StubbornComponent style={{width}}/>
}
I would’ve preferred a pure-CSS solution, but this seems to be working and the code is temporary (well, moreso than usual, hopefully)