I think you take the issue in the wrong way.
You should never rely on resize during initial view.
So your slider code have an issue on sizing which is typical when dealing with images (read the width before the image is loaded).
But if you still want to try that way
It may be depends on where do you dispatch this event ? If you dispatch it before your Slider is renderered it will not work.
A solution could be to use React.useEffect:
function MySlider() {
React.useEffect(() => {
// dispatch it once mounted
window.dispatchEvent(new Event('resize'));
}, []);
return <div>Your stuff</div>
}