You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In InteractiveMap, the onLoad event seems to call setState, which is usually fine, except when the load event is fired during a render. So far this reproduces reliable within a synchronous browser-based unit test environment, but it is probably nondeterministic enough to not be easy to reproduce in actual usage. Nevertheless, looking at the error and stack trace (which are included below), there doesn't seem to be anything which prevents this from happening in the wild.
Throwing a setTimeout around the onLoad handler works to get rid of the error, but is probably not the best solution.
This seems similar to #872 in terms of what's going on (a render leads to an event which then leads to a setState call).
In this case, it seems during render of StaticMap we call _renderOverlays which leads to setting the size, and hence calling mapbox-gl redraw, which notices that the map became loaded but we haven't fired the load event, and so fires it. This calls InteractiveMap onLoad which calls setState, hence leading to the problem.
Error message
Warning: Cannot update during an existing state transition (such as within `render`). Render methods should be a pure function of props and state.
in AutoSizer (created by StaticMap)
in div (created by StaticMap)
in StaticMap (created by InteractiveMap)
in div (created by InteractiveMap)
in InteractiveMap (at <censored>)
<censored>
In InteractiveMap, the onLoad event seems to call
setState
, which is usually fine, except when the load event is fired during a render. So far this reproduces reliable within a synchronous browser-based unit test environment, but it is probably nondeterministic enough to not be easy to reproduce in actual usage. Nevertheless, looking at the error and stack trace (which are included below), there doesn't seem to be anything which prevents this from happening in the wild.Throwing a
setTimeout
around the onLoad handler works to get rid of the error, but is probably not the best solution.This seems similar to #872 in terms of what's going on (a render leads to an event which then leads to a setState call).
In this case, it seems during
render
ofStaticMap
we call_renderOverlays
which leads to setting the size, and hence calling mapbox-gl redraw, which notices that the map became loaded but we haven't fired the load event, and so fires it. This calls InteractiveMap onLoad which calls setState, hence leading to the problem.Error message
Stack trace
Tested with v5.2.7, mapbox-gl 1.8.1.
The text was updated successfully, but these errors were encountered: