Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
rpm-mcarman b9f7ec4306 First Commit 4 лет назад
..
es First Commit 4 лет назад
LICENSE First Commit 4 лет назад
README.md First Commit 4 лет назад
forwardRef.d.ts First Commit 4 лет назад
forwardRef.js First Commit 4 лет назад
index.d.ts First Commit 4 лет назад
index.js First Commit 4 лет назад
injectContextAsProp.js First Commit 4 лет назад
mapContextToProps.d.ts First Commit 4 лет назад
mapContextToProps.js First Commit 4 лет назад
package.json First Commit 4 лет назад
transformContext.js First Commit 4 лет назад

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