Is there a way to persist a layout for a given set of routes?
September 26, 2018 at 11:04amThe Next.js community has a new home. This thread is preserved for historical purposes. The content of this conversation may be innaccurrate or out of date. Go to new community home →
Is there a way to persist a layout for a given set of routes?
September 26, 2018 at 11:04amI see that you can modify _app.js to persist a layout between pages. But lets say I have a /home, /about, and /login page that I don't want a persisted layout. But then I have /dashboard /dashboard/clients /dashboard/statistics where I want a dashboard layout to persist. Is there a way to achieve this? Thanks :)
September 26, 2018 at 11:15am
September 26, 2018 at 7:19pm
September 27, 2018 at 10:30pm
September 28, 2018 at 11:40am
Oh I guess it's as simple as passing a function from _app.js down haha. Sometimes when trying something new things seem like magic. Glad next is so simple. Thanks for this idea!
_error.js:
import React from 'react'export default class Error extends React.Component {static getInitialProps ({ res, err }) {const statusCode = res ? res.statusCode : err ? err.statusCode : nullreturn { statusCode }}static isErrorPage = truerender () {return (<h1>{this.props.statusCode? `An error ${this.props.statusCode} occurred on server`: 'An error occurred on client'}</h1>)}}