Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Function passed as undefined when on a tag with an `each` loop #2474

Closed
Kangaroux opened this issue Oct 27, 2017 · 0 comments
Closed

Function passed as undefined when on a tag with an `each` loop #2474

Kangaroux opened this issue Oct 27, 2017 · 0 comments
Labels

Comments

@Kangaroux
Copy link

@Kangaroux Kangaroux commented Oct 27, 2017

  1. Describe your issue:

A child tag that is defined using each to create multiple tags will not properly pass functions through as an opt. A workaround is to wrap the child tag in a virtual, and put the each on the virtual tag instead.

  1. Can you reproduce the issue?

http://plnkr.co/edit/d2eUK48kBzsiJriSJ64b?p=preview

<my-tag>
  <h2>Clicked { clicked } times</h2>
  
  <p>Wrapped in a virtual tag:</p>
  <virtual each={ stuff }>
    <child-tag func-click={ clickBtn } />
  </virtual>
  
  <p>No virtual tag:</p>
  
  <child-tag each={ stuff } func-click={ clickBtn } />

  <script>
    this.clicked = 0;
    this.stuff = [0,0,0,0,0];
    
    clickBtn() {
      this.update({
        clicked: this.clicked + 1
      });
    }
  </script>
</my-tag>


<child-tag>
  <button onclick={ opts.funcClick }>
    { typeof opts.funcClick }
  </button>
</child-tag>
  1. On which browser/OS does the issue appear?

Firefox 56 win10

  1. Which version of Riot does it affect?

Riot 3.7.3

  1. How would you tag this issue?
  • Question
  • Bug
  • Discussion
  • Feature request
  • Tip
  • Enhancement
  • Performance
@Kangaroux Kangaroux mentioned this issue Oct 27, 2017
1 of 7 tasks complete
GianlucaGuarini added a commit that referenced this issue Nov 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.