Dashboard sipadu mbip
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
root d8c1b4a1be initial vor 5 Jahren
..
es initial vor 5 Jahren
LICENSE initial vor 5 Jahren
README.md initial vor 5 Jahren
forwardRef.d.ts initial vor 5 Jahren
forwardRef.js initial vor 5 Jahren
index.d.ts initial vor 5 Jahren
index.js initial vor 5 Jahren
injectContextAsProp.js initial vor 5 Jahren
mapContextToProps.d.ts initial vor 5 Jahren
mapContextToProps.js initial vor 5 Jahren
package.json initial vor 5 Jahren
transformContext.js initial vor 5 Jahren

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