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

Not working with Next.js version 13.5.2 React 18.2.0 Hydration #32

Open
andresvpineros opened this issue Oct 21, 2023 · 1 comment
Open

Comments

@andresvpineros
Copy link

While adding the component inside an client component, I get these errors related with next hydration:

Warning: Text content did not match. Server: "s" Client: "x"
Warning: An error occurred during hydration. The server HTML was replaced with client content in <#document>.
Uncaught Error: There was an error while hydrating. Because the error happened outside of a Suspense boundary, the entire root will switch to client rendering.

@jmne
Copy link

jmne commented Oct 23, 2023

You need to check if client rendering is being used:

"use client";
import { RandomReveal } from "react-random-reveal";
import { useEffect, useState } from "react";

const Test = () => {
  const [isClient, setIsClient] = useState(false);

  useEffect(() => {
    setIsClient(true);
  }, []);
  return (
            <span>
              {isClient ? (
                <RandomReveal
                  isPlaying
                  duration={5}
                  characters="?????"
                  updateInterval={0.1}
                  characterSet={["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"]}
                />
              ) : (
                "?????"
              )}
            </span>
  );
};

export default Test;

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

2 participants