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

Nested component support #31

Open
davidjamesstone opened this issue Nov 15, 2020 · 0 comments
Open

Nested component support #31

davidjamesstone opened this issue Nov 15, 2020 · 0 comments

Comments

@davidjamesstone
Copy link

davidjamesstone commented Nov 15, 2020

Hi @mardix - nice library. I really like the API.

I've been playing around with it though and I can't get nested components to work correctly.
Can you see if I'm doing something incorrectly?

<script type="module">
  import Litedom from "//unpkg.com/litedom";

  Litedom({
    tagName: "hello-world",
    template: `
      <div>
        {this.greeting} {this.prop.name}!
        <hello-child name={this.greeting}></hello-child>
        <button @click="changeGreeting">Click</button>
      </div>`,
    data: {
      greeting: "Hello"
    },
    changeGreeting(event) {
      this.data.greeting = "Goodbye";
    }
  });
  Litedom({
    tagName: "hello-child",
    template: `<i>{this.foo} {this.prop.name}!</i>`,
    data: {
      foo: "Bar"
    }
  });
</script>

<hello-world name="Mardix"> </hello-world>

This code renders fine first time but if I click the button, the greeting state is changed, the component re-renders but the child component, <hello-child>, loses its data and props.

You can see it here

Anyone have any suggestions?

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

No branches or pull requests

1 participant