Git Product home page Git Product logo

next-layout's People

Contributors

dependabot[bot] avatar satazor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

next-layout's Issues

Use separately for each page instead of _app

Hey,

is it possible to use withLayout for each page?

My setup currently:

export const authenticated = (Component) => {
  return withLayout(<AuthGuard><BaseLayout /></AuthGuard>)(Component)
}

export const public = (Component) => {
  return withLayout(<BaseLayout />)(Component)
}

in each page i then use either authenticated(Component) or public(Component)

AuthGuard:

const AuthCheck = ({ children }) => {
  const [isChecking, setChecking] = React.useState(true)
  const router = useRouter()
  const actions = useActions()
  const state = useState()

  React.useEffect(() => {
    tryAuth()
  }, [])

  React.useEffect(() => {
    if (state.authenticationCheckFailed) {
      redirect()
    }
  }, [state.authenticationCheckFailed])

  React.useEffect(() => {
    if (state.authenticationCheckTried && state.isAuthenticated) {
      setChecking(false)
    }
  }, [state.authenticationCheckTried])

  const redirect = async () => {
    const r = router.pathname.slice(1)
    const redirectTo = r === 'login' ? '/' : '/' + r
    router.push(`/login?r=${redirectTo}`)
    // setChecking(false)
  }

  const tryAuth = async () => {
    await actions.checkAuth(null)
  }

  if (isChecking) {
    return (
      <Centered>
        <LoadingSpinner $style={{ borderTopColor: theme.colors.primary }} />
      </Centered>
    )
  }

  return children
}

export default AuthCheck

however this doesn't seem to work with SSR, it still is rendering my page Component first, then it renders my , even though it should not render any page component until (isChecking) is set to false (which happens if the user was authenticated)

Pass props from each page to layout

Hello.

With this library is it possible to pass props from different pages to the layout component?

For example, imagine:

  • I have a contacts page, about page and a MainLayout.
  • want to pass some props to MainLayout from the contacts page but different props from the about page.

Greetings and thanks for the library.

Deprecate in favor of app directory

Hi, I had this bookmarked for a while to try it out sometime, but I want to ask - should this package be "deprecated" in favor of next.js 13's new app directory feature? At least to put into README a disclaimer that such a feature exists now and is probably preferable.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.