Dashboard sipadu mbip
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
root d8c1b4a1be initial 6年前
..
es initial 6年前
LICENSE initial 6年前
README.md initial 6年前
forwardRef.d.ts initial 6年前
forwardRef.js initial 6年前
index.d.ts initial 6年前
index.js initial 6年前
injectContextAsProp.js initial 6年前
mapContextToProps.d.ts initial 6年前
mapContextToProps.js initial 6年前
package.json initial 6年前
transformContext.js initial 6年前

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