From 11b29ae5b7bdb476b3a28c564d3f761ed707d27f Mon Sep 17 00:00:00 2001 From: Tejas Kumar Date: Wed, 8 Aug 2018 15:21:22 +0200 Subject: [PATCH] Update examples --- README.md | 51 ++++++++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index e5977346..756166e2 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ import Get from "restful-react"; const MyComponent = () => ( - {randomDogImage => Here's a good boye!} + {randomDogImage => Here's a good boye!} ); @@ -130,28 +130,33 @@ Here's some docs about the [RequestInit](https://developer.mozilla.org/en-US/doc ```jsx // Assuming we're using a RestfulProvider with base={HOST} somewhere, - - {data => { - return ( -
-

Here are my cats!

- {data.map(cat => {cat.name})} - - {/* Request BASE/cats/persian */} - - {persianCats => { - return ( -
-

Here are my persian cats!

- {persianCats.map(cat => {cat.name})} -
- ); - }} -
-
- ); - }} -
+import React from "react"; +import Get from "restful-react"; + +export default () => ( + {/* Use the lazy prop to not send a request */} + + {data => { + return ( +
+

Random Image

+ {/* Composes path with parent: sends request to /breeds/image/random */} + + {image => Random Image} + + +

All Breeds

+ {/* Composes path with parent: sends request to /breeds/list */} + + {list => ( +
    {list && list.message.map(dogName =>
  • {dogName}
  • )}
+ )} +
+
+ ); + }} +
+); ``` From the above example, _not only_ does the path accumulate based on the nesting of each `Get`, but each `Get` _can_ override its parent with other props as well: including having _specific_ `requestOptions` if there was a valid use case.