Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/silvestreh/feathers-react
A FeathersJS real-time React component library to display data
https://github.com/silvestreh/feathers-react
Last synced: about 2 months ago
JSON representation
A FeathersJS real-time React component library to display data
- Host: GitHub
- URL: https://github.com/silvestreh/feathers-react
- Owner: silvestreh
- Created: 2019-10-27T21:05:18.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-03-15T05:47:38.000Z (almost 2 years ago)
- Last Synced: 2024-10-28T22:33:37.443Z (3 months ago)
- Language: JavaScript
- Size: 2.69 MB
- Stars: 8
- Watchers: 1
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-feathersjs - feathers-react - A FeathersJS real-time React component library to display data (Frontend frameworks / React and Redux)
README
# feathers-react [![CircleCI](https://circleci.com/gh/silvestreh/feathers-react.svg?style=svg)](https://circleci.com/gh/silvestreh/feathers-react) [![codecov](https://codecov.io/gh/silvestreh/feathers-react/branch/master/graph/badge.svg?token=X8yCXb8yva)](https://codecov.io/gh/silvestreh/feathers-react)
> A [Feathers](https://www.feathersjs.com) real-time React component library to display data
## Install
```bash
npm install --save feathers-react
```## Documentation
`feathers-react` consists of just a handful of React Components to help you display data coming from your Feathers API in real-time. Make sure to go through the [channels docs](https://docs.feathersjs.com/api/channels.html) to set up real-time events, otherwise the components won't update _automagically_.
### Table props
| Name | Description | Required | Default value |
|------|-------------|----------|---------------|
| `service` | The Feathers service to get data from. | Yes | `undefined` |
| `query` | A [Feathers query](https://docs.feathersjs.com/api/databases/querying.html) object to run against the specified `service`. | No | `{}` |
| `keyProp` | The result's property to use as `key`. | No | `'id'` |
| `onRowClick` | Click event handler for a table row. The function takes two arguments: the row's data and its `index`. | No | `(row, index) => {}` |
| `sortable` | A `Boolean` that determines wether a header can be clicked to sort results | No | `undefined` |
| `onDataChange` | A callback `Function` that is invoked after the table's data changed | No | `undefined` |
| `countTemplate` | A string to use as template for showing items count. For example, `'Showing {start} to {end} of {total}'` would render something like `Showing 1 to 10 of 25`. | No | `undefined` |
| `language` | The locale name to render translated text. Supported locales are `['fr_FR', 'en_US', 'es_ES']`. | No | `'en_US'` |
| `usePagination` | Determines wether to use the `` component. | No | `true` |
| `paginationProps` | An `Object` to override [`rc-pagination`](https://github.com/react-component/pagination)'s props. | No | `undefined` |### Column props
| Name | Description | Required | Default value |
|------|-------------|----------|---------------|
| `dataSource` | The result's property to extract data from. | Only when `render` is not defined | `undefined` |
| `render` | A render function that takes two arguments: the data for the column and the row's data. For example, `imageUrl => ` would render an image in the table cell. | No | `undefined` |
| `title` | A string to use as the header for the column. | No | `undefined` |
| `width` | The column's visual width, in pixels. | No | `undefined` |### Example
In this simple example, the `` component takes a `client` prop which is a [Feathers client](https://docs.feathersjs.com/api/authentication/client.html).
```jsx
import React from 'react';
import { Column, Table } from 'feathers-react';
import 'feathers-react/style.css';export default ({ client }) => {
const service = client.service('some-service');
const query = { $sort: { name: 1 } };return (
(
)} />
);
};
```### Container props
The `` component is a generic wrapper that you can use to present data in a different format than tabular. It shares most props with the `` component, the main difference is that it doesn't take any children, but has a `renderItem` prop to render data.
| Name | Description | Required | Default value |
|------|-------------|----------|---------------|
| `service` | The Feathers service to get data from. | Yes | `undefined` |
| `query` | A [Feathers query](https://docs.feathersjs.com/api/databases/querying.html) object to run against the specified `service`. | No | `{}` |
| `emptyState` | An HTMLElement, React component, or String to render when there are no results. | No | `undefined` |
| `keyProp` | The result's property to use as `key`. | No | `'id'` |
| `renderItem` | A render function that can return a React component. The function takes two arguments: the row's data and its `index`. | Yes | `(row, index) => ` |
| `itemsWrapper` | An HTMLElement or React component that will wrap rendered children. | No | `undefined` |
| `separator` | A render function to use as a separator. It takes one argument: the current result being iterated. It requires both: `itemsWrapper` and `query.$sort` to be defined. | No | `undefined` |
| `countTemplate` | A string to use as template for showing items count. For example, `'Showing {start} to {end} of {total}'` would render something like `Showing 1 to 10 of 25`. | No | `undefined` |
| `language` | The locale name to render translated text. Supported locales are `['fr_FR', 'en_US', 'es_ES']`. | No | `'en_US'` |
| `usePagination` | Determines wether to use the `` component. | No | `false` |
| `hidePaginationOnSinglePage` | Hides the pagination component when there's only one page of data | No | `undefined` |
| `paginationProps` | An `Object` to override [`rc-pagination`](https://github.com/react-component/pagination)'s props. | No | `undefined` |### Example
```jsx
import React from 'react';
import { Container } from 'feathers-react';
import 'feathers-react/style.css';
import Message from './message';export default ({ client }) => {
const service = client.service('messages');
const query = { $sort: { author: 1 } };return (
}
separator={message =>Messages by {message.author}
}
renderItem={message => (
)} />
);
};
```## License
MIT © [Silvestre Herrera](https://github.com/silvestreh)