You're looking for the setTimeout()
function from the React library, here's some information from the docs itself: https://react.dev/learn/synchronizing-with-effects#putting-it-all-together
Your solution would be adding a slight delay to the mapbox resize with the usage of the setTimeout
check the sandbox here:
https://codesandbox.io/p/sandbox/epic-napier-2lpf29
Goodluck!