You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Toying a bit with webdev recently (I am far from being a web developer), I've been trying to integrate a Google sign-in button into one of the prominent yew examples out there. At first, the button did not appear at all, and later I managed to make it appear only once after initial load, and not after refreshes.
After trying to add this same button to the todomvc example, I reached the same result there too. Now, given that there is no error shown in the web browser console, and all resources loaded correctly, and recalling that yew does DOM management behind the scene, this led me to thinking perhaps yew is too aggressive in how it manages the DOM. Is it possible that Google's script are able to insert the button but Yew later removes it? The 'div element still exists but it is empty of sub-elements. Not too versed in web development, I am not sure how to debug this yet, and thought perhaps someone here may give some clue on how to proceed.
The text was updated successfully, but these errors were encountered:
That is a tricky situation. Google is doing some magic to render that button and indeed Yew could very well interfere with that magic.
The problem is most likely that the div you're rendering (the one that Google eventually turns into a sign-in button) is inside of a Component that gets re-rendered. When that happens, Yew tries to be smart and only update DOM elements that it needs to. But Yew is actually still pretty dumb and so if the DOM tree changes even slightly, it will recreate your div (and will lose all of Google's magic rendering).
If you can structure your app in a way that avoid re-rendering the component that is displaying that sign in button div, then you should be able to avoid this issue.
In order to access the JS api, you can use the stdwebjs! macro to access window.gapi or you could use wasm-bindgen to create a Rust interface for the api methods you need.
Thanks! I've added a js!{} block in the fn mounted() of the login component to call the gapi.signin2.render function, and it seems to have fixed the issue.
Toying a bit with webdev recently (I am far from being a web developer), I've been trying to integrate a Google sign-in button into one of the prominent yew examples out there. At first, the button did not appear at all, and later I managed to make it appear only once after initial load, and not after refreshes.
After trying to add this same button to the
todomvc
example, I reached the same result there too. Now, given that there is no error shown in the web browser console, and all resources loaded correctly, and recalling thatyew
does DOM management behind the scene, this led me to thinking perhapsyew
is too aggressive in how it manages the DOM. Is it possible that Google's script are able to insert the button but Yew later removes it? The'div
element still exists but it is empty of sub-elements. Not too versed in web development, I am not sure how to debug this yet, and thought perhaps someone here may give some clue on how to proceed.The text was updated successfully, but these errors were encountered: