|
1 | | -# @rc-component/context |
| 1 | +<div align="center"> |
| 2 | + <h1>@rc-component/context</h1> |
| 3 | + <p><sub><a href="https://ant.design"><img alt="Ant Design" height="14" src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg" style="vertical-align: -0.125em;" /></a> Part of the Ant Design ecosystem.</sub></p> |
| 4 | + <p>🔁 Performant React context selector utilities for rc-component packages.</p> |
2 | 5 |
|
3 | | ---- |
| 6 | + <p> |
| 7 | + <a href="https://npmjs.org/package/@rc-component/context"><img alt="NPM version" src="https://img.shields.io/npm/v/@rc-component/context.svg?style=flat-square"></a> |
| 8 | + <a href="https://npmjs.org/package/@rc-component/context"><img alt="npm downloads" src="https://img.shields.io/npm/dm/@rc-component/context.svg?style=flat-square"></a> |
| 9 | + <a href="https://github.com/react-component/context/actions/workflows/test.yml"><img alt="build status" src="https://github.com/react-component/context/actions/workflows/test.yml/badge.svg"></a> |
| 10 | + <a href="https://app.codecov.io/gh/react-component/context"><img alt="Codecov" src="https://img.shields.io/codecov/c/github/react-component/context/master.svg?style=flat-square"></a> |
| 11 | + <a href="https://bundlephobia.com/package/@rc-component/context"><img alt="bundle size" src="https://img.shields.io/bundlephobia/minzip/@rc-component/context?style=flat-square"></a> |
| 12 | + <a href="https://github.com/umijs/dumi"><img alt="dumi" src="https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square"></a> |
| 13 | + </p> |
| 14 | +</div> |
4 | 15 |
|
5 | | -React way perf context selector |
| 16 | +<p align="center">English | <a href="./README.zh-CN.md">简体中文</a></p> |
6 | 17 |
|
7 | | -[![NPM version][npm-image]][npm-url] [![build status][github-actions-image]][github-actions-url] [![Codecov][codecov-image]][codecov-url] [![node version][node-image]][node-url] [![npm download][download-image]][download-url] |
| 18 | +## Highlights |
8 | 19 |
|
9 | | -[npm-image]: http://img.shields.io/npm/v/@rc-component/context.svg?style=flat-square |
10 | | -[npm-url]: http://npmjs.org/package/@rc-component/context |
11 | | -[github-actions-image]: https://github.com/react-component/context/workflows/CI/badge.svg |
12 | | -[github-actions-url]: https://github.com/react-component/context/actions |
13 | | -[codecov-image]: https://img.shields.io/codecov/c/github/react-component/context/master.svg?style=flat-square |
14 | | -[codecov-url]: https://app.codecov.io/gh/react-component/context |
15 | | -[node-image]: https://img.shields.io/badge/node.js-%3E=_0.10-green.svg?style=flat-square |
16 | | -[node-url]: http://nodejs.org/download/ |
17 | | -[download-image]: https://img.shields.io/npm/dm/@rc-component/context.svg?style=flat-square |
18 | | -[download-url]: https://npmjs.org/package/@rc-component/context |
| 20 | +| Area | Support | |
| 21 | +| ------- | ---------------------------------------------------------------------- | |
| 22 | +| Purpose | Performant React context selector utilities for rc-component packages. | |
| 23 | +| Package | `@rc-component/context` | |
| 24 | +| Release | `@rc-component/np` / `rc-np` | |
19 | 25 |
|
20 | | -## Development |
| 26 | +## Install |
21 | 27 |
|
| 28 | +```bash |
| 29 | +npm install @rc-component/context |
22 | 30 | ``` |
| 31 | + |
| 32 | +## Usage |
| 33 | + |
| 34 | +```tsx | pure |
| 35 | +import { createContext } from '@rc-component/context'; |
| 36 | + |
| 37 | +const [Provider, useContext] = createContext({ count: 0 }); |
| 38 | + |
| 39 | +export { Provider, useContext }; |
| 40 | +``` |
| 41 | + |
| 42 | +## API |
| 43 | + |
| 44 | +| API | Description | |
| 45 | +| ----------------------------- | -------------------------------------------------- | |
| 46 | +| `createContext(defaultValue)` | Create a provider and selector-aware context hook. | |
| 47 | + |
| 48 | +## Development |
| 49 | + |
| 50 | +```bash |
23 | 51 | npm install |
24 | 52 | npm start |
| 53 | +npm test |
| 54 | +npm run lint |
| 55 | +npm run tsc |
| 56 | +npm run compile |
25 | 57 | ``` |
| 58 | + |
| 59 | +The dumi site runs at `http://localhost:8000`. |
| 60 | + |
| 61 | +## Release |
| 62 | + |
| 63 | +```bash |
| 64 | +npm run prepublishOnly |
| 65 | +``` |
| 66 | + |
| 67 | +The release flow is handled by `@rc-component/np` through the `rc-np` command when the package uses the shared release flow. |
| 68 | + |
| 69 | +## License |
| 70 | + |
| 71 | +@rc-component/context is released under the [MIT](./LICENSE.md) license. |
0 commit comments