Skip to content

LitHauntedElement: No re-render observed when incoming prop changed  #341

@barryf001

Description

@barryf001

Hi,

Relates to LitElementHaunted usage.

Could you explain why when a state variable is passed to a child component (as per example code) there is no re-rendering of the child component? Maybe I'm using this incorrectly but this seems the most intutive usage..

import { html } from 'lit-element';
import { litHaunted } from './lit-haunted-element.js';
import { useState } from 'haunted'


const CounterChild = litHaunted(({count}) => {

  return html`
    <h1>${count}</h1>
  `;
});

window.customElements.define('my-counter-child', CounterChild);


const Counter = litHaunted(() => {

  const [count, setCount] = useState(0);

  return html`
      <p>A paragraph</p>
      <button type="button" @click=${() => { setCount(count + 1)}}>Increment</button>
      <p><strong>Count:</strong> ${count}</p>
    <div>
    <my-counter-child .count=${count}></my-counter-child>
   </div>
  `;
});

window.customElements.define('my-counter', Counter);

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