Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Any way to pass properties to SVGROOT? #10

Open
MozilaIP opened this issue May 9, 2019 · 1 comment
Open

Any way to pass properties to SVGROOT? #10

MozilaIP opened this issue May 9, 2019 · 1 comment

Comments

@MozilaIP
Copy link

MozilaIP commented May 9, 2019

Hi, In my app I need to pass some variable data to be drawn.

Example:

<Ellipse cy={this.state.y} cx={this.state.x} />

But I am unable to do this since svgRoot does not inherit properties from parent component.
Moreover, I want svgRoot to execute render on state change, but, as written above, I can't pass any state to it, hence this component is not reactive.

Is there any workaround for my issue?

@msand
Copy link
Owner

msand commented May 9, 2019

Check how the onToggle handler is passed in the readme example:

In App component

  childProps = { onToggle: this.onToggle };

In App render / ZoomableSvg element props

          childProps={this.childProps}

In SvgRoot onPress event handler:

    const { onToggle } = this.props;
    if (onToggle) {
      onToggle();
    }

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants