Skip to content

Get the initialization event to use draw.(...) #187

@CMonjo

Description

@CMonjo

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):

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 :(

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions