mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
* add typings for react-request * fix react-request types * remove reference path * try specifying a typescript version in index.d.ts * pin to 2.9 instead of 2.9.2 * fix linting issues * fix index.d.ts lint issues
23 lines
544 B
TypeScript
23 lines
544 B
TypeScript
import * as React from "react";
|
|
import { Fetch } from "react-request";
|
|
|
|
interface ServerResponse {
|
|
foo: string;
|
|
}
|
|
|
|
export default class BasicReactRequest extends React.Component {
|
|
render() {
|
|
return <Fetch<ServerResponse> url='/api/server'>
|
|
{({ fetching, failed, data, response }) => {
|
|
if (fetching || !response) {
|
|
return <p>Loading...</p>;
|
|
}
|
|
if (failed) {
|
|
return <h2>Failed to load</h2>;
|
|
}
|
|
return <p>{data ? data.foo : 'data was null'}</p>;
|
|
}}
|
|
</Fetch>;
|
|
}
|
|
}
|