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

AOS with NextJS - Document is not defined #709

Closed
trupakufi opened this issue Aug 22, 2021 · 6 comments
Closed

AOS with NextJS - Document is not defined #709

trupakufi opened this issue Aug 22, 2021 · 6 comments

Comments

@trupakufi
Copy link

trupakufi commented Aug 22, 2021

  • BUG

Specifications

  • AOS version: 3.0
  • OS: Windows 10
  • Browser: Google Chrome

Document is Not Defined

So, I throug that the aos work normaly with nextjs, but I met with a problem in document, my eslint says that document is not defined

Captura de ecrã de 2021-08-22 21-38-00

And in the browser a see this.!

Captura de ecrã de 2021-08-22 21-40-50

I try catch the bug using dynamic import but nothing instead.!

@GeniusHawlah
Copy link

I am facing the same problem right now. Were you able to solve it?

@aman-maharshi
Copy link

aman-maharshi commented Dec 3, 2021

Calling the init() inside useEffect worked for me

useEffect(() => {
        AOS.init()
}, [])

@Princekrampah
Copy link

Princekrampah commented May 5, 2022

import 'bootstrap/dist/css/bootstrap.min.css';
import '../styles/globals.css';
import '../styles/header.css';
import Layout from "../components/Layout";
import { useEffect } from "react";

import AOS from 'aos';
import 'aos/dist/aos.css'; 




function MyApp({ Component, pageProps }) {
  
  useEffect(() => {
    AOS.init({
      startEvent: 'DOMContentLoaded', 
      initClassName: 'aos-init',
      animatedClassName: 'aos-animate'
    });
  }, [])

  return (
    <>
      <Layout>
        <Component {...pageProps} />
      </Layout>
    </>
  )
}

export default MyApp

@nicefella
Copy link

Calling the init() inside useEffect worked for me

useEffect(() => {
        AOS.init()
}, [])

You are an amazingly maniac problem solver! Thank you!

@htamagnus
Copy link

I try:
`import { useEffect } from "react";
import AOS from 'aos';
import 'aos/dist/aos.css';

useEffect(() => {
AOS.init({
startEvent: 'DOMContentLoaded',
initClassName: 'aos-init',
animatedClassName: 'aos-animate'
});
}, [])`

and now I have this error:
`TypeError: Cannot read properties of null (reading 'useEffect')

`

@apophis51
Copy link

Calling the init() inside useEffect worked for me

useEffect(() => {
        AOS.init()
}, [])

YOU ARE A BRO!

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

7 participants