Doesn't work with scss modules in react.js
dmelechow opened this issue · 3 comments
dmelechow commented
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
any updates??
mongsukim commented
i have same problem...
MarcusBYUI commented
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;