Lit-html: repeat not working

Created on 22 Dec 2018  路  8Comments  路  Source: Polymer/lit-html

render() {
return html<ul>${repeat(this.itemsList, (todo) => todo.id, (todo) => html\

  • ${todo.item}\
  • </ul>;
    }
    (note : backticks are removed by formating)
    returns
    (...args) => { const d = f(...args); directives.set(d, true); return d; } not the html list.

    My itemsList is:
    [{"id":1545488867446,"item":"kam todo","done":false},{"id":1545488871284,"item":"hello","done":false},{"id":1545488877314,"item":"new hello","done":false}]

    Most helpful comment

    Reopening because I am seeing this same issue. Using lit-html and lit-element together. This simple component causes the same issue ((...args) => { const d = f(...args); directives.set(d, true); return d; } is printed on the page):

      render() {
        var test = ["apple","orange","banana"];
        return html`
          <div>
            ${repeat(test, (test) => html`<h3>${test}</h3>`)}
          </div>
        `
      }
    

    All 8 comments

    if by "returns" you mean "renders onto the page" then check if you have multiple copies of lit-html being used (e.g. more than one copy in your node_modules tree)

    Thanks Captain, Yes its renders on the page. I will check for duplicate lit-html.

    This is likely caused by multiple version of lit-html. Run npm dedupe and then check your package-lock.

    Thanks.

    Reopening because I am seeing this same issue. Using lit-html and lit-element together. This simple component causes the same issue ((...args) => { const d = f(...args); directives.set(d, true); return d; } is printed on the page):

      render() {
        var test = ["apple","orange","banana"];
        return html`
          <div>
            ${repeat(test, (test) => html`<h3>${test}</h3>`)}
          </div>
        `
      }
    

    Have the same problem in a lit-element and desperately looking for a fast way to bind large arrays

    Did you read justin's answer to this issue?

    Try npm dedupe or delete package-lock.json and node_modules and
    reinstall.

    Was this page helpful?
    0 / 5 - 0 ratings