Skip to content

Commit

Permalink
Merge c9833aa into 3276438
Browse files Browse the repository at this point in the history
  • Loading branch information
diogofcunha committed Oct 7, 2018
2 parents 3276438 + c9833aa commit 6bebcdd
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .travis.yml
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
48 changes: 48 additions & 0 deletions README.md
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 |

0 comments on commit 6bebcdd

Please sign in to comment.