-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Main.js #2338
Comments
You can simply import libraries anywhere You need, and if they are already imported, then it will not be downloaded again to client-side (onMount will be triggered, but import will be done from cache instead of Internet),... There is issue about how load and onMount runs in You can write me about Your problem on discord. |
@Mlocik97 ok thank you I will experiment with the if(browser) and onload functions. I suppose I'll just give my full confusions at moment even if multiple questions put together. First kept having issues trying to use aws amplify in svelte and thought was aws amplify issue but anyway ended up adding a script to index.html that worked aws-amplify/amplify-cli#8050 So I import that in __layout.svelte as such. I just added context="module" because I think that makes sense for layout anyway cause only is one layout but let me know if should remove. Also maybe this is where i should use onload and put Amplify.configure(awsconfig); in it
Side note (can you not make a route like index / index.svelte with folder like other routes? Was doing Layout component to put all Layout files in a place. Anyway then have Layout folder like this
So key visible issue I'm having with this is the because I have code to trigger modal from anywhere by just adding number to a store value and as long as value is over initial value it opens the modal. So when I start the first load its fine and say I'm on settings page and hit sign in on navbar it increments openModalWatch and triggers the open. Then if I clicked a new route because it was remounting or instantiating whatever word is the layout again it would rerun Actually I think it works fine when I run fresh
|
Describe the problem
Other things like vue.js have a main.js where you put overarching single time imports for app. I can't for the life of me figure out the recommended equivalent. I tried asking in discord and get ignored. I try using __layout script because in all elements but i notice it remounts on new route views
Describe the proposed solution
Only run __layout once and on route views only run the rest of stuff but only have one initial load of __layout
Alternatives considered
Trying some kind of
let hasMounted = false
in store or something and on mount of layout check if hasMounted already before doing somethingImportance
would make my life easier
Additional Information
No response
The text was updated successfully, but these errors were encountered: