next-page-decorator-invariant

0.1.2 • Public • Published

Next.js page decorator invariant helper CircleCI

A decorator warns developers about incorrect usage of Next.js page decorators

Summary

When developing reusable decorators that target Next.js pages (which may or may not have a getInitialProps) it's useful to assert that the wrapped components is a page and not an ordinary component. For improved developer experience wrap any reusable page decorator with PageDecoratorInvariant and an error will be emitted when the decorator is improperly used.

Usage

  1. Install into your reusable component

    yarn add next-page-decorator-invariant
    
  2. Use the decorator

    Configure the decorator and use it inside your decorator

    // decorators/FooDecorator.js
    import PageDecoratorInvariant from 'next-page-decorator-invariant'
    const pageDecoratorInvariant = PageDecoratorInvariant('FooDecorator')
    
    default export Page => {
      const WrappedPage = pageDecoratorInvariant(Page)
      return props => <WrappedPage {...props} />
    }
    

/next-page-decorator-invariant/

    Package Sidebar

    Install

    npm i next-page-decorator-invariant

    Weekly Downloads

    2

    Version

    0.1.2

    License

    MIT

    Last publish

    Collaborators

    • possibilities