25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

README.md 808 B

3 yıl önce
1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # @restart/context [![npm][npm-badge]][npm]
  2. React context helpers.
  3. ## Install
  4. ```sh
  5. npm install @restart/context
  6. ```
  7. ## Usage
  8. ```js
  9. import React from 'react';
  10. import mapContextToProps from '@restart/context/mapContextToProps';
  11. const MyValueContext = React.createContext(null);
  12. function MyComponent(props) {
  13. /* ... */
  14. }
  15. const MyComponentWithMyValue = mapContextToProps(
  16. MyValueContext,
  17. myValue => ({ myValue }),
  18. MyComponent,
  19. );
  20. const withMyValue = Component =>
  21. mapContextToProps(
  22. {
  23. consumers: MyValueContext,
  24. mapToProps: myValue => ({ myValue }),
  25. displayName: `withMyValue(${Component.displayName || Component.name})`,
  26. },
  27. Component,
  28. );
  29. ```
  30. [npm-badge]: https://img.shields.io/npm/v/@restart/context.svg
  31. [npm]: https://www.npmjs.org/package/@restart/context