0.9.2 • Published 6 years ago
react-aqueduct v0.9.2
react-aqueduct
The bridge to convey
waterdata
Installation
npm install --save react-aqueduct
Example
import React from 'react';
import { createRequest } from 'react-aqueduct';
const PeopleSearch = createRequest([], ({ name }) =>
fetch(`https://swapi.co/api/people/?search=${name}`)
.then(response => response.json())
.then(json => json.results),
);
const renderItem = item => <li>{item.name}</li>;
class App extends React.Component {
state = { name: '' };
handleChange = ({ currentTarget }) => {
this.setState({ name: currentTarget.value });
};
render() {
return (
<section>
<h1>Start Wars Search</h1>
<input
placeholder="Yoda"
value={this.state.name}
onChange={this.handleChange}
/>
<PeopleSearch
name={this.state.name}
render={({ data, isLoading }) =>
isLoading ? <div>Loading...</div> : <ul>{data.map(renderItem)}</ul>
}
/>
</section>
);
}
}
export default App;
See examples on codesanbox:
0.9.2
6 years ago
0.9.1
6 years ago
0.9.0
6 years ago
0.8.4
6 years ago
0.8.3
6 years ago
0.8.2
6 years ago
0.8.1
6 years ago
0.8.0
6 years ago
0.7.1
6 years ago
0.7.0
6 years ago
0.6.0
6 years ago
0.5.1
6 years ago
0.5.0
6 years ago
0.4.3
6 years ago
0.4.2
6 years ago
0.4.1
6 years ago
0.3.0
6 years ago
0.2.0
6 years ago
0.1.0
6 years ago