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.
 
 
 
 
rpm-mcarman b9f7ec4306 First Commit пре 3 година
..
es First Commit пре 3 година
LICENSE First Commit пре 3 година
README.md First Commit пре 3 година
forwardRef.d.ts First Commit пре 3 година
forwardRef.js First Commit пре 3 година
index.d.ts First Commit пре 3 година
index.js First Commit пре 3 година
injectContextAsProp.js First Commit пре 3 година
mapContextToProps.d.ts First Commit пре 3 година
mapContextToProps.js First Commit пре 3 година
package.json First Commit пре 3 година
transformContext.js First Commit пре 3 година

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