Gazebo_simulation-Frontend/node_modules/@restart/context
Riddhi Dave f4870cd530 simulator page updates 2020-12-22 09:59:14 -05:00
..
es React files 2020-12-21 10:29:31 -05:00
LICENSE React files 2020-12-21 10:29:31 -05:00
README.md React files 2020-12-21 10:29:31 -05:00
forwardRef.d.ts React files 2020-12-21 10:29:31 -05:00
forwardRef.js React files 2020-12-21 10:29:31 -05:00
index.d.ts React files 2020-12-21 10:29:31 -05:00
index.js React files 2020-12-21 10:29:31 -05:00
injectContextAsProp.js React files 2020-12-21 10:29:31 -05:00
mapContextToProps.d.ts React files 2020-12-21 10:29:31 -05:00
mapContextToProps.js React files 2020-12-21 10:29:31 -05:00
package.json simulator page updates 2020-12-22 09:59:14 -05:00
transformContext.js React files 2020-12-21 10:29:31 -05:00

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