An open API service indexing awesome lists of open source software.

https://github.com/bebo/react-simple-fetch

React component to fetch() data and automatically bind the result as props for the child component(s).
https://github.com/bebo/react-simple-fetch

Last synced: about 2 months ago
JSON representation

React component to fetch() data and automatically bind the result as props for the child component(s).

Awesome Lists containing this project

README

        

# react-simple-fetch

React component to fetch() data and automatically bind the result as props for the child component(s).

## Get it

```npm install react-simple-fetch --save```

## Usage

```jsx
import SimpleFetch from 'react-simple-fetch';

```

The props types of the `SimpleFetch` component are:

```js
type Props = {
children: , // yes a single react element
url: string,
path: ?string, // defaults to ''
as: ?string, // defaults to 'fetched' (your data would be in your child compoent as 'this.props.fetched')
forceHttps: ?bool, // defaults to true (turn any URL you pass to https)
mapResponse: ?any, // defaults to 'auto' (other options are true and false) [can usually be left on 'auto mode']
loader: ?, // pass any jsx dom or component that should be rendered while we go out and fetch the data
};
```

## Examples

#### Object Result
```jsx

// will render once the fetch() returns
// will have the returned data available on 'this.props.repo'

```

#### Array Result
```jsx

// will render once the fetch() returns
// as the result is an Array we will automatically map over it and render as many elements as necessary
// individual elements will have their data available on 'this.props.star'

```

### (More & better docs coming soon...)

## Contributing

Bug reports and pull requests are welcome on GitHub. This project is intended to be a
safe, welcoming space for collaboration, and contributors are expected to adhere
to the [Contributor Covenant](http://contributor-covenant.org/) code of conduct.

## License

```
_________________
< The MIT License >
-----------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
```