Skip to content
This repository has been archived by the owner on Nov 11, 2023. It is now read-only.

Add: Getting started with react native and editable example on expo #161

Merged
merged 1 commit into from
Oct 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 57 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,33 @@ As an abstraction, this tool allows for greater consistency and maintainability
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

- [Overview](#overview)
- [Getting Started](#getting-started)
- [Features](#features)
- [Global Configuration](#global-configuration)
- [`RestfulProvider` API](#restfulprovider-api)
- [Composability](#composability)
- [Full `Get` Component API](#full-get-component-api)
- [Loading and Error States](#loading-and-error-states)
- [Lazy Fetching](#lazy-fetching)
- [Response Resolution](#response-resolution)
- [Debouncing Requests](#debouncing-requests)
- [TypeScript Integration](#typescript-integration)
- [Query Parameters](#query-parameters)
- [Mutations with `Mutate`](#mutations-with-mutate)
- [Full `Mutate` Component API](#full-mutate-component-api)
- [Polling with `Poll`](#polling-with-poll)
- [Long Polling](#long-polling)
- [Full `Poll` Component API](#full-poll-component-api)
- [Code Generation](#code-generation)
- [Usage](#usage)
- [Import from GitHub](#import-from-github)
- [Transforming an Original Spec](#transforming-an-original-spec)
- [Caching](#caching)
- [Contributing](#contributing)
- [Code](#code)
- [Dogfooding](#dogfooding)
- [Next Steps](#next-steps)
- [`restful-react`](#restful-react)
- [Overview](#overview)
- [Getting Started](#getting-started)
- [Features](#features)
- [Global Configuration](#global-configuration)
- [`RestfulProvider` API](#restfulprovider-api)
- [Loading and Error States](#loading-and-error-states)
- [Lazy Fetching](#lazy-fetching)
- [Response Resolution](#response-resolution)
- [Debouncing Requests](#debouncing-requests)
- [TypeScript Integration](#typescript-integration)
- [Query Parameters](#query-parameters)
- [Mutations with `useMutate`](#mutations-with-usemutate)
- [Polling with `Poll`](#polling-with-poll)
- [Long Polling](#long-polling)
- [Full `Poll` Component API](#full-poll-component-api)
- [Code Generation](#code-generation)
- [Usage](#usage)
- [Validation of the OpenAPI specification](#validation-of-the-openapi-specification)
- [Import from GitHub](#import-from-github)
- [Transforming an Original Spec](#transforming-an-original-spec)
- [Advanced configuration](#advanced-configuration)
- [Config File Format](#config-file-format)
- [Config File Example](#config-file-example)
- [Contributing](#contributing)
- [Code](#code)
- [Next Steps](#next-steps)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

Expand All @@ -58,6 +58,36 @@ const MyComponent = () => {
export default MyComponent;
```

and on React Native,
[Edit restful-react basic demo on Expo](https://snack.expo.io/SJaSAj49r)

```jsx
import { AppRegistry, Image } from "react-native";
import React from "react";

import { useGet } from "restful-react";

const App = () => {
const { data: randomDogImage } = useGet({
path: "https://dog.ceo/api/breeds/image/random",
});
return (
<>
{randomDogImage && (
<Image
style={{ width: 250, height: 250 }}
source={{
uri: randomDogImage.message,
}}
/>
)}
</>
);
};

AppRegistry.registerComponent("react-native-app", () => App);
```

## Getting Started

To install and use this library, install it by running `yarn add restful-react`, or `npm i restful-react --save` and you should be good to go. Don't forget to `import { useGet } from "restful-react"` or similar wherever you need it!
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"npm-run-all": "^4.1.5",
"prettier": "^1.16.4",
"react-dom": "^16.8.5",
"react": "^16.8.5",
"react-hooks-testing-library": "^0.5.0",
"react-test-renderer": "^16.8.6",
"react-testing-library": "^7.0.0",
Expand All @@ -97,14 +98,13 @@
"lodash": "^4.17.11",
"openapi3-ts": "^0.12.0",
"qs": "^6.6.0",
"react": "^16.8.4",
"react-fast-compare": "^2.0.4",
"request": "^2.88.0",
"swagger2openapi": "^3.2.14",
"url": "^0.11.0",
"yamljs": "^0.3.0"
},
"peerDependencies": {
"react": "^16.8.4"
"react": ">=16.8.5"
}
}
9 changes: 4 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7575,15 +7575,14 @@ react-testing-library@^7.0.0:
"@babel/runtime" "^7.4.3"
dom-testing-library "^4.0.0"

react@^16.8.4:
version "16.8.5"
resolved "https://registry.yarnpkg.com/react/-/react-16.8.5.tgz#49be3b655489d74504ad994016407e8a0445de66"
integrity sha512-daCb9TD6FZGvJ3sg8da1tRAtIuw29PbKZW++NN4wqkbEvxL+bZpaaYb4xuftW/SpXmgacf1skXl/ddX6CdOlDw==
react@^16.8.5:
version "16.11.0"
resolved "https://registry.yarnpkg.com/react/-/react-16.11.0.tgz#d294545fe62299ccee83363599bf904e4a07fdbb"
integrity sha512-M5Y8yITaLmU0ynd0r1Yvfq98Rmll6q8AxaEe88c8e7LxO8fZ2cNgmFt0aGAS9wzf1Ao32NKXtCl+/tVVtkxq6g==
dependencies:
loose-envify "^1.1.0"
object-assign "^4.1.1"
prop-types "^15.6.2"
scheduler "^0.13.5"

read-pkg-up@^4.0.0:
version "4.0.0"
Expand Down