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).
- Host: GitHub
- URL: https://github.com/bebo/react-simple-fetch
- Owner: bebo
- License: mit
- Created: 2016-09-01T02:38:47.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-09-01T10:15:23.000Z (over 8 years ago)
- Last Synced: 2025-03-10T21:41:13.231Z (2 months ago)
- Language: JavaScript
- Homepage:
- Size: 13.7 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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 |
|| ||
```