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.
Siti Rahayu d7b21f8c27 latest 4 years ago
..
es latest 4 years ago
LICENSE latest 4 years ago
README.md latest 4 years ago
forwardRef.d.ts latest 4 years ago
forwardRef.js latest 4 years ago
index.d.ts latest 4 years ago
index.js latest 4 years ago
injectContextAsProp.js latest 4 years ago
mapContextToProps.d.ts latest 4 years ago
mapContextToProps.js latest 4 years ago
package.json latest 4 years ago
transformContext.js latest 4 years ago

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