enhance-dev / enhance-ssr

Server side render for custom elements.
144 stars 9 forks source link

Typo in "attrs as keys" figure on the store doc page. #31

Closed luv2code closed 2 years ago

luv2code commented 2 years ago

In the store doc page, the code figure reads like this:

export default function MyElement({ html, state }) {
  const { attrs, store } = state
  const { message='', bookId='' } = attrs
  const { books={} } = store
  const book = books.bookId
  const bookTitle = book.title || ''

  return html`
    <div>
      <h3>${bookTitle}</h3>
    </div>
  `
}

I believe it should read like so (using the bookId string to index into the books store object):

export default function MyElement({ html, state }) {
  const { attrs, store } = state
  const { message='', bookId='' } = attrs
  const { books={} } = store
  const book = books[bookId]
  const bookTitle = book.title || ''

  return html`
    <div>
      <h3>${bookTitle}</h3>
    </div>
  `
}
ryanblock commented 2 years ago

Totally, another excellent find. Thank you, this will be live in a few minutes!