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

Widget double rendering #30

Open
farzeni opened this issue Aug 24, 2018 · 2 comments
Open

Widget double rendering #30

farzeni opened this issue Aug 24, 2018 · 2 comments

Comments

@farzeni
Copy link

farzeni commented Aug 24, 2018

Hi,
First, thank you for this good lib.

I have a problem embedding a widget created with preact-habitat in one Wordpress site. I'm embedding the widget inline, inside a div.

It happens that 'loaded' function (https://github.com/zouhir/preact-habitat/blob/master/src/index.js#L23) is called twice and the last time is called 'window.currentScript' is null so the function 'getExecutedScript' (https://github.com/zouhir/preact-habitat/blob/master/src/lib.js#L20) returns the last script in the page, which is another one different from injection script and the widget is rendered another time at the bottom of the page.

I tryed to reproduce this bug in a clean environment, but without success. This wp site (like many) is a mess of scripts and I really don't know which is the one causing this problem.

I solved my issue adding a variable in 'render' function to control if widget was already rendered, see:

master...farzeni:master

do you have an idea what can be the cause of the problem? or do you think this solution can be merged?

@importerror
Copy link

@zouhir Seems legit for widget. Any solutions for this?

@zouhir
Copy link
Owner

zouhir commented Sep 6, 2018

sorry I've missed this! that's strange & interesting @farzeni @importerror ...

I will be investigating closely & hopefully deploy a fix asap.

fwiw, @farzeni - your fork's fix look legit

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

3 participants