Giter Club home page Giter Club logo

Comments (10)

dwalks12 avatar dwalks12 commented on September 27, 2024 3

I was able to solve this by following tutods method but importing it into my layout file like this:

const AosInit = dynamic(() => import('./<path>/AOSInit'), { ssr: true });

(Remember to export AOSInit as default)

from aos.

tutods avatar tutods commented on September 27, 2024

Does anyone have any idea how to fix this in the Next 13?

from aos.

tomlschmidt avatar tomlschmidt commented on September 27, 2024

When and how do you call AOS.init()? AOS is adding the class aos-init during initialization. At hydration, Next.js then experiences a mismatch between the server and client. I'm not that experienced with Next.js, but I'm guessing that's the problem. A possible solution might be calling AOS.init() in an effect. More information on the issue, you can find here: https://nextjs.org/docs/messages/react-hydration-error

from aos.

tutods avatar tutods commented on September 27, 2024

I handle the AOS.init() in a "use client" component:

'use client';

import AOS from 'aos';
import type { ReactNode } from 'react';
import { useEffect } from 'react';

import 'aos/dist/aos.css';

export const AosInit = ({ children }: { children: ReactNode }) => {
  useEffect(() => {
    AOS.init({
      anchorPlacement: 'top-bottom',
      mirror: true,
      offset: -100,
      once: false,
    });
  }, []);

  return <>{children}</>;
};

from aos.

tutods avatar tutods commented on September 27, 2024

After that only call this component in my layout:
image

from aos.

renovatt avatar renovatt commented on September 27, 2024

I have the same problem using Next.js 13+, did you manage to solve it?

from aos.

tutods avatar tutods commented on September 27, 2024

Hi @renovatt, no.
Already try a few things, but no success.

from aos.

renovatt avatar renovatt commented on September 27, 2024

I also can't understand it, because I'm using it in other projects and I don't have this problem, I've already updated all the dependencies and nothing works, I removed some providers around it and also without success. I can not understand. @tutods

from aos.

tutods avatar tutods commented on September 27, 2024

Thanks @renovatt

from aos.

VernSG avatar VernSG commented on September 27, 2024

It seems like you're encountering a warning about a prop mismatch related to the className attribute when using AOS (Animate on Scroll) in your Next.js project. This warning typically occurs when the className generated on the server-side rendering (SSR) doesn't match the one generated on the client-side. This can happen if there's a difference in how components are rendered between server and client.

One common approach to address this is to ensure that components are rendered consistently on both the server and client sides. You might want to check if there are any dynamic or conditional rendering that could cause differences between SSR and client-side rendering. Additionally, you can use libraries like react-async-script to load AOS dynamically on the client side, which might help mitigate this issue.

from aos.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.