Skip to content

Commit

Permalink
Add a README to every example (#79)
Browse files Browse the repository at this point in the history
* Correct examples name in their package.json

* Add a README to every example

- How to download only this examples
- How to install their dependencies and run it
- How to deploy it to Now
- What the examples are about

* Remove yarn.lock files of each examples

This way you will always get the latest version of SWR

* Update examples package.json files to include react, react-dom and latest version of swr

* Update README files to remove the command to install react, react-dom and swr
  • Loading branch information
sergiodxa authored and shuding committed Nov 5, 2019
1 parent a2d700b commit e9451bc
Show file tree
Hide file tree
Showing 27 changed files with 304 additions and 49,211 deletions.
30 changes: 30 additions & 0 deletions examples/api-hooks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# API Hooks

## How to Use

Download the example:

```bash
curl https://codeload.github.com/zeit/swr/tar.gz/master | tar -xz --strip=2 swr-master/examples/api-hooks
cd api-hooks
```

Install it and run:

```bash
yarn
yarn dev
# or
npm install
npm run dev
```

Deploy it to the cloud with [now](https://zeit.co/home) ([download](https://zeit.co/download))

```
now
```

## The Idea behind the Example

Show how you could create custom hooks, using SWR internally, for your different data requirements and use them in your application.
8 changes: 5 additions & 3 deletions examples/api-hooks/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{
"name": "basic",
"name": "api-hooks",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"swr": "link:../..",
"isomorphic-unfetch": "3.0.0",
"next": "9.1.1"
"next": "9.1.1",
"react": "16.11.0",
"react-dom": "16.11.0",
"swr": "latest"
},
"scripts": {
"dev": "next",
Expand Down
5,483 changes: 0 additions & 5,483 deletions examples/api-hooks/yarn.lock

This file was deleted.

30 changes: 30 additions & 0 deletions examples/basic-typescript/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Basic TypeScript

## How to Use

Download the example:

```bash
curl https://codeload.github.com/zeit/swr/tar.gz/master | tar -xz --strip=2 swr-master/examples/basic-typescript
cd basic-typescript
```

Install it and run:

```bash
yarn
yarn dev
# or
npm install
npm run dev
```

Deploy it to the cloud with [now](https://zeit.co/home) ([download](https://zeit.co/download))

```
now
```

## The Idea behind the Example

Show how to use the basic example along with TypeScript to type the data received from SWR.
6 changes: 4 additions & 2 deletions examples/basic-typescript/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{
"name": "basic",
"name": "basic-typescript",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"isomorphic-unfetch": "3.0.0",
"next": "9.1.1",
"swr": "link:../.."
"react": "16.11.0",
"react-dom": "16.11.0",
"swr": "0.1.6"
},
"scripts": {
"dev": "next",
Expand Down

0 comments on commit e9451bc

Please sign in to comment.