Dashboard sipadu mbip
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
root d8c1b4a1be initial преди 5 години
..
es initial преди 5 години
LICENSE initial преди 5 години
README.md initial преди 5 години
forwardRef.d.ts initial преди 5 години
forwardRef.js initial преди 5 години
index.d.ts initial преди 5 години
index.js initial преди 5 години
injectContextAsProp.js initial преди 5 години
mapContextToProps.d.ts initial преди 5 години
mapContextToProps.js initial преди 5 години
package.json initial преди 5 години
transformContext.js initial преди 5 години

README.md

@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,
  );