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
First of all a big congratulations for the package it is really great and very useful for my use! :)
I cannot solve a problem, despite the fact that I have read all the documentation several times.
I initiate my DrawControl component this way with a ref to be able to use draw.()
<DrawControl ref={(drawControl) => { this.drawControl = drawControl; }}/>
When my parent component is assembled, in componentDidMount I would like to be able to follow an API call to draw all the features that I have recovered. Like this :
this.drawControl.draw.add(feature);
I get this error (normal):
Unhandled Rejection (TypeError): Cannot read property 'draw' of undefined
How do I know when is the DrawControl component init and the draw function usable?
Thank you very much! Hoping to find an answer :(
The text was updated successfully, but these errors were encountered:
I had a similar issue, except I wanted my features to draw whenever I add a feature to the component state. Updating the component state forced the whole component, including the Map and DrawControl, to re-render and I would get the same error.
A temporary workaround is to do setTimeout(this.drawControl.draw.add(feature), 1000), which simply waits 1000ms before it calls add(). This lets the DrawControl ref initialize before add() gets called, but I'm certain there's a better solution.
Hello,
First of all a big congratulations for the package it is really great and very useful for my use! :)
I cannot solve a problem, despite the fact that I have read all the documentation several times.
I initiate my DrawControl component this way with a ref to be able to use draw.()
<DrawControl ref={(drawControl) => { this.drawControl = drawControl; }}/>
When my parent component is assembled, in componentDidMount I would like to be able to follow an API call to draw all the features that I have recovered. Like this :
this.drawControl.draw.add(feature);
I get this error (normal):
How do I know when is the DrawControl component init and the draw function usable?
Thank you very much! Hoping to find an answer :(
The text was updated successfully, but these errors were encountered: