Non-Potable Macchiato

    @restart/context
    TypeScript icon, indicating that this package has built-in type declarations

    2.1.4 • Public • Published

    @restart/context npm

    React context helpers.

    Install

    npm install @restart/context

    Usage

    import React from 'react';
    import mapContextToProps from '@restart/context/mapContextToProps';
    
    const MyValueContext = React.createContext(null);
    
    function MyComponent(props) {
      /* ... */
    }
    
    const MyComponentWithMyValue = mapContextToProps(
      MyValueContext,
      myValue => ({ myValue }),
      MyComponent,
    );
    
    const withMyValue = Component =>
      mapContextToProps(
        {
          consumers: MyValueContext,
          mapToProps: myValue => ({ myValue }),
          displayName: `withMyValue(${Component.displayName || Component.name})`,
        },
        Component,
      );

    Keywords

    none

    Install

    npm i @restart/context

    DownloadsWeekly Downloads

    774,782

    Version

    2.1.4

    License

    MIT

    Unpacked Size

    22.8 kB

    Total Files

    19

    Last publish

    Collaborators

    • kytsang
    • monastic.panic
    • taion