stereobooster / react-snap

👻 Zero-configuration framework-agnostic static prerendering for SPAs
MIT License
5.04k stars 389 forks source link

Doesn't work with scss modules in react.js #535

Open dmelechow opened 3 years ago

dmelechow commented 3 years ago

I use the default setup react-snap from the main page for my ReactJS project.

In my project, I use scss modules for styling separately almost for every component, and after building and running the project some styles of elements are lost or are mixed.

sandeepDevJs commented 2 years ago

any updates??

mongsukim commented 2 years ago

i have same problem...

MarcusBYUI commented 1 year ago

Here is how I fixed a similar issue:

Apparently it has something to do with rehydration process of react: this article was a guide to understanging the siolution: https://www.joshwcomeau.com/react/the-perils-of-rehydration/#:~:text=to%20this%20heading-,The%20solution,-To%20avoid%20issues

const ComponentToBeRenderedOnAnotherRoutePath = () => {
  const [hasMounted, setHasMounted] = useState(false);

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

  if (!hasMounted) {
    return null;
  } else
    return <>your code</>
};

export default ComponentToBeRenderedOnAnotherRoutePath;