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

Double rendering on some components #2981

Open
1 task done
damusix opened this issue Aug 3, 2023 · 3 comments
Open
1 task done

Double rendering on some components #2981

damusix opened this issue Aug 3, 2023 · 3 comments

Comments

@damusix
Copy link
Contributor

damusix commented Aug 3, 2023

Help us to manage our issues by answering the following:

  1. Describe your issue:

Sometimes, randomly, a component will double the elements inside of it.

  1. Can you reproduce the issue?

No, but I have screenshots of the issue

  1. On which browser/OS does the issue appear?

Latest chrome

  1. Which version of Riot does it affect?

Riot 7

  1. How would you tag this issue?
  • Bug

Screenshot 2023-08-03 at 12 44 47 PM
Screenshot 2023-08-03 at 12 45 03 PM
Screenshot 2023-08-03 at 12 45 28 PM
Screenshot 2023-08-03 at 12 45 44 PM

@GianlucaGuarini
Copy link
Member

I have tried to replicate the issue with this demo https://plnkr.co/edit/icOhGsihhg5y4MWQ but I had no luck so far. Are you sure that your html is valid and you are closing your tags properly?

@damusix
Copy link
Contributor Author

damusix commented Aug 15, 2023

@GianlucaGuarini I think I know why it's happening, I just can't replicate.

The above is a different context under which the double renders are happening. Below is another specific scenario:

  • I have a custom built router on my app.
  • I riot.install(...) an enhancer that, onMounted, it redirects to whatever component.defaultRoute is.
  • I also expose the router via window.router

Given the following:

{ 
    onMounted() { window.router.goTo('/somewhere'); }, 
    defaultRoute: '/somewhere/else' 
}

I get the double render issue.

What I posted up top is similar, but a different reason as to why it double renders (still looking for the first one)

I think something might be happening where it fails to clean up the old HTML elements or they are overwritten when there are too many rerender attempts.

My router is simple:

route.riot

<route>

    <template if="{ shouldShow() }">
        <slot />
    </template>

    <script>
        export default {
            ...,
            shouldShow() {

                if (currentRoute does not match this.path) {
                     return false;
                }

                return true;
            }
        }
    </script>
</route>

and the thing that listens to a route change simply re-renders the component using routeComponent.update({ show:true })

... anyway, that's just context to explain that, something is going on that it's not cleaning up old HTML and rendering next to it.

@GianlucaGuarini
Copy link
Member

Also with the code provided I am not able to reproduce the issue https://plnkr.co/edit/3wWRvhDsDy5MWrXR. Without a reproducible example it's really hard for me to help you out. I will keep this issue open in case someone else could come out with a better idea

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

No branches or pull requests

2 participants