Optimizing Scripts
Unanswered
Schweizerischer Niederlaufhund posted this in #help-forum
Schweizerischer NiederlaufhundOP
Hi!
I've been, after a long day, able to implement the useInView hook and make it work. Currently all of the code implementation happens in the FrontPage.tsx file.
But according to Next documentation a script can be optimixed by using next/script. But after playing around with this for a long time I'm not able to implement it according to the docs.
In the folder Hooks I've made a useInView.ts file with the script needed, but I don't understand the implementation structure.
I've tried implementing it in layout.tsx in app folder, but generally my issue is that the
So, summarized – how do I structure and implement the useInView script in the Hooks folder into the FrontPage.tsx using Script optimization ala the Next docs:
https://nextjs.org/docs/app/building-your-application/optimizing/scripts
Repo:
https://github.com/AMarlonG/Website/tree/main/web-app
I've been, after a long day, able to implement the useInView hook and make it work. Currently all of the code implementation happens in the FrontPage.tsx file.
But according to Next documentation a script can be optimixed by using next/script. But after playing around with this for a long time I'm not able to implement it according to the docs.
In the folder Hooks I've made a useInView.ts file with the script needed, but I don't understand the implementation structure.
I've tried implementing it in layout.tsx in app folder, but generally my issue is that the
myRef prop isn't being found.So, summarized – how do I structure and implement the useInView script in the Hooks folder into the FrontPage.tsx using Script optimization ala the Next docs:
https://nextjs.org/docs/app/building-your-application/optimizing/scripts
Repo:
https://github.com/AMarlonG/Website/tree/main/web-app