Open MosheZemah opened 1 month ago
Before using remix-island, I was able to add body class from routes like this:
function App() { ... const matches = useMatches() as UIMatch<unknown, { bodyClass: string }>[]; const routeBodyClasses = matches .filter((match) => match.handle?.bodyClass) .map((match) => match.handle?.bodyClass) .join(' '); ... return ( ... <body className={routeBodyClasses}> ...
and in the specific route component:
export const handle: Handler<LoaderData> = { bodyClass: 'some-class', };
Is it possible to also do it now?
I've added the classes using useEffect in root:
useEffect(() => { routeBodyClasses.split(' ').forEach((className) => document.body.classList.add(className)); }, [routeBodyClasses]);
Before using remix-island, I was able to add body class from routes like this:
and in the specific route component:
Is it possible to also do it now?