To have multiple layouts within the app. We wouldn't want all pages to share the same layout.
Oh ! That make sense. Maybe it could be easier with a custom hook then ? Like :
import { useState } from "react"; const FirstLayout = ({ children }) => { const [counter, setCounter] = useState(0); return ( <> <p> First Layout <button onClick={() => setCounter(counter + 1)}> Clicked {counter} Times </button> </p> {children} </> ) } export default FirstLayout export function withFirstLayout (Component){ Component.Layout = FirstLayout return Component }
and the page :
import { withFirstLayout } from 'layout/FirstLayout' const Home = () => { return <div> index </div> } export default withFirstLayout(Home)
But when we change the layout we still have a reset of the old one
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
To have multiple layouts within the app. We wouldn't want all pages to share the same layout.
Oh ! That make sense. Maybe it could be easier with a custom hook then ?
Like :
and the page :
But when we change the layout we still have a reset of the old one