fix-hydration
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

fix-hydration

It is a simple package to tackle hydration error in Next.js.

Context

if you ever worked on working with next.js definitely encountered hydration error. if can be fixed by simple code like -

 const [isMounted, setIsMounted] = useState(false);

  useEffect(() => {
    setIsMounted(true);
  }, []);

  if (!isMounted) {
    return null;
  }

And but obviously you have to dig in your codebase and find which component is giving hydration error and just paste this code on top of it , it will be fixed. But writing this become repitative task so you can use this package.

How to use

npm i fix-hydration
import useFixHydration from "fix-hydration"


const componentinwhichHydrationerroristhere = () => {

const hasMounted=useFixHydration()

if(!hasMounted){
 return null
}

}

Published By

faisal husain

Readme

Keywords

none

Package Sidebar

Install

npm i fix-hydration

Weekly Downloads

3

Version

1.0.2

License

ISC

Unpacked Size

2.63 kB

Total Files

7

Last publish

Collaborators

  • faisal004