-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
sudo: false | ||
|
||
language: node_js | ||
node_js: | ||
- 8 | ||
|
||
before_install: | ||
- npm install codecov.io coveralls | ||
|
||
script: | ||
- yarn build | ||
- yarn test --coverage | ||
|
||
after_success: | ||
- cat ./coverage/lcov.info | ./node_modules/codecov.io/bin/codecov.io.js | ||
- cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js | ||
- npx semantic-release | ||
|
||
branches: | ||
only: | ||
- master | ||
|
||
env: | ||
global: | ||
- CI: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# react-to-component | ||
|
||
[![Travis][build-badge]][build] | ||
[![npm package][npm-badge]][npm] | ||
[![Coveralls][coveralls-badge]][coveralls] | ||
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) | ||
|
||
[build-badge]: https://img.shields.io/travis/diogofcunha/react-to-component/master.png?style=flat-square | ||
[build]: https://travis-ci.org/diogofcunha/react-to-component | ||
[npm-badge]: https://img.shields.io/npm/v/react-to-component.png?style=flat-square | ||
[npm]: https://www.npmjs.com/package/react-to-component | ||
[coveralls-badge]: https://img.shields.io/coveralls/diogofcunha/react-to-component/master.png?style=flat-square | ||
[coveralls]: https://coveralls.io/github/diogofcunha/react-to-component | ||
|
||
:rocket: Blazing fast and tiny library that enables you to **create react components (componentify)** imperative or functional apis. | ||
|
||
## Install | ||
|
||
```shell | ||
yarn add react-to-component | ||
``` | ||
|
||
## Aims to be: | ||
|
||
- :rocket: Blazing fast | ||
- ➿Defensive code friendly | ||
- :rage2: Async first | ||
- 🔧 Memory leak safe | ||
- :ring: Test friendly | ||
|
||
## A quick example | ||
|
||
```typescript | ||
<ToComponent original={oldLegacyCodeApi} params={[1, 2, 3]}> | ||
{({ loading, error, data }) => | ||
loading ? "Loading" : error ? "Oops, error" : JSON.stringify(data) | ||
} | ||
</ToComponent> | ||
``` | ||
|
||
## Configuration | ||
|
||
| Prop | Required | Default | Type | Description | | ||
| ------------------- | -------- | --------------- | --------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | | ||
| original | ✔️ | ✖️ | `(...params: P[]) => Promise<T> | T` | The original function to be encapsulated | | ||
| params | ✔️ | ✖️ | `P[]` | The params that will be used in the function invocation | | ||
| children | ✔️ | ✖️ | `({ data: T | null, error: Error | null, loading: boolean }) => JSX.Element | JSX.Element[] | null` | The render prop that controls you data flow | | ||
| parametersDidChange | ✖️ | Params equality | `(previousParams: P[], nextParams: P[]) => boolean` | Ability to supply a custom check for parameter equality, use this if for example you need to ignore some parameters for caching purposes | |