Skip to content

Questions about state between nested components #238

Closed
@oren

Description

@oren

I have App.html and a child component - Login.html.
When the user submit the login form the Login component calls the server endpoint and on success I change user.loggedIn to true and add a user key to the localStorage. The problem is the App.html should be aware of it so it can change it's content and remove some UI elements (link to login for example).

  1. Is this the right approach?
  2. If SSR and progressive enhancement #1 is 'yes', how do I communicate this with the parent component?
  3. Since I use this router, the new keyword is not being used. How to access the component API from the parent (App.html)?

Here is my example repo:
https://github.com/oren/svelte-router-example/blob/c638c8786084a327bffdcac99da13b55695667cb/src/components/Login.html

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions