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