Skip to content

Commit 5a7cee9

Browse files
authored
Release v10 (#214)
Release v10
2 parents 43698be + c78dfea commit 5a7cee9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+2105
-913
lines changed

.all-contributorsrc

+19
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,25 @@
212212
"contributions": [
213213
"ideas"
214214
]
215+
},
216+
{
217+
"login": "AlixWang",
218+
"name": "AlixWang",
219+
"avatar_url": "https://avatars0.githubusercontent.com/u/5417459?v=4",
220+
"profile": "https://github.com/AlixWang",
221+
"contributions": [
222+
"doc"
223+
]
224+
},
225+
{
226+
"login": "salolivares",
227+
"name": "Sal Olivares",
228+
"avatar_url": "https://avatars0.githubusercontent.com/u/1812749?v=4",
229+
"profile": "http://salolivares.com",
230+
"contributions": [
231+
"code",
232+
"bug"
233+
]
215234
}
216235
],
217236
"contributorsPerLine": 7,

.circleci/config.yml

+2-28
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- restore_cache:
1919
name: Restore root dependencies from cache
2020
keys:
21-
- root-dependencies-v1-{{ checksum "yarn.lock" }}
21+
- root-dependencies-v1-{{ checksum "package.json" }}
2222
- run:
2323
name: Install dependencies
2424
command: yarn install
@@ -27,15 +27,14 @@ jobs:
2727
command: yarn bootstrap
2828
- save_cache:
2929
name: Cache root dependencies
30-
key: root-dependencies-v1-{{ checksum "yarn.lock" }}
30+
key: root-dependencies-v1-{{ checksum "package.json" }}
3131
paths:
3232
- ~/.cache/yarn
3333
- run: yarn build:packages
3434
- persist_to_workspace:
3535
root: .
3636
paths:
3737
- node_modules
38-
- examples
3938
- packages
4039
lint:
4140
<<: *defaults
@@ -64,28 +63,6 @@ jobs:
6463
- attach_workspace:
6564
at: .
6665
- run: bash <(curl -s https://codecov.io/bash)
67-
examples:
68-
<<: *defaults
69-
steps:
70-
- checkout
71-
- attach_workspace:
72-
at: .
73-
- run:
74-
name: Bootstrap
75-
command: yarn bootstrap
76-
- run:
77-
name: Build examples
78-
command: yarn build:examples
79-
- run:
80-
name: Test examples
81-
command: yarn test:examples --maxWorkers=2
82-
- run:
83-
name: Deploy examples
84-
command: |
85-
if [ "${CIRCLE_BRANCH}" == "master" ]; then
86-
yarn deploy:examples
87-
fi
88-
no_output_timeout: 30m
8966
chromatic:
9067
<<: *defaults
9168
steps:
@@ -108,9 +85,6 @@ workflows:
10885
- coverage:
10986
requires:
11087
- test
111-
- examples:
112-
requires:
113-
- build
11488
- chromatic:
11589
requires:
11690
- build

.eslintrc

+14-2
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,17 @@
2020
"react": {
2121
"version": "detect"
2222
}
23-
}
24-
}
23+
},
24+
"overrides": [{
25+
"files": "packages/**/*.{ts,tsx}",
26+
"parser": "@typescript-eslint/parser",
27+
"plugins": ["@typescript-eslint"],
28+
"parserOptions": {
29+
"ecmaVersion": 6,
30+
"sourceType": "module",
31+
"ecmaFeatures": {
32+
"modules": true
33+
}
34+
}
35+
}]
36+
}

.github/workflows/examples.yml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Build, test and deploy examples
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
name: Build on node ${{ matrix.node_version }} and ${{ matrix.os }}
8+
runs-on: ${{ matrix.os }}
9+
strategy:
10+
matrix:
11+
os: [ubuntu-latest]
12+
node: [10]
13+
steps:
14+
- uses: actions/setup-node@v1
15+
with:
16+
node-version: "10.x"
17+
- uses: actions/checkout@v1
18+
- name: Cache node modules
19+
id: cache-modules
20+
uses: actions/cache@v1
21+
with:
22+
path: node_modules
23+
key: ${{ runner.OS }}-build-${{ hashFiles('**/package.json') }}
24+
restore-keys: |
25+
${{ runner.OS }}-build-${{ env.cache-name }}-
26+
${{ runner.OS }}-build-
27+
${{ runner.OS }}-
28+
- name: Install
29+
if: steps.cache-modules.outputs.cache-hit != 'true'
30+
run: yarn install
31+
- name: Bootstrap
32+
run: yarn bootstrap
33+
- name: Build examples
34+
run: yarn build:examples
35+
- name: Test examples
36+
run: yarn test:examples --maxWorkers=2
37+
- name: Deploy examples
38+
if: github.ref == 'master'
39+
run: yarn deploy:examples

.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
save-exact=true

.storybook/webpack.config.js

+8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
module.exports = async ({ config }) => {
22
delete config.module.rules[0].include
3+
config.module.rules.push({
4+
test: /\.(ts|tsx)$/,
5+
loader: require.resolve('babel-loader'),
6+
options: {
7+
presets: [['react-app', { flow: false, typescript: true }]],
8+
},
9+
});
10+
config.resolve.extensions.push('.ts', '.tsx');
311
return config
412
}

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ cache:
55
yarn: true
66
directories:
77
- node_modules
8-
script: yarn ci
8+
script: yarn && yarn ci
99
after_success:
1010
- bash <(curl -s https://codecov.io/bash) -e TRAVIS_NODE_VERSION

README.md

+29-19
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,12 @@
1717
<img src="https://badgen.net/npm/dm/react-async" alt="montly downloads">
1818
</a>
1919
<a href="https://bundlephobia.com/result?p=react-async">
20-
<img src="https://badgen.net/bundlephobia/min/react-async" alt="minified size">
20+
<img src="https://badgen.net/bundlephobia/minzip/react-async" alt="minzipped size">
2121
</a>
2222
<a href="https://opensource.org/licenses/ISC">
2323
<img src="https://badgen.net/npm/license/react-async" alt="license">
2424
</a>
2525
<br/>
26-
<a href="https://github.com/async-library/react-async/issues">
27-
<img src="https://badgen.net/github/open-issues/async-library/react-async?icon=github" alt="issues">
28-
</a>
29-
<a href="https://github.com/async-library/react-async/pulls">
30-
<img src="https://badgen.net/github/open-prs/async-library/react-async?icon=github" alt="pull requests">
31-
</a>
32-
<a href="https://github.com/async-library/react-async/releases">
33-
<img src="https://badgen.net/github/releases/async-library/react-async?icon=github" alt="releases">
34-
</a>
35-
<a href="https://github.com/async-library/react-async/graphs/contributors">
36-
<img src="https://badgen.net/github/contributors/async-library/react-async?icon=github" alt="contributors">
37-
</a>
38-
<br/>
3926
<a href="https://circleci.com/gh/async-library/react-async">
4027
<img src="https://badgen.net/circleci/github/async-library/react-async/master?icon=circleci" alt="circleci status">
4128
</a>
@@ -52,10 +39,6 @@
5239
<img src="https://deepscan.io/api/teams/5549/projects/7406/branches/74183/badge/grade.svg" alt="DeepScan grade">
5340
</a>
5441
<br/>
55-
<img src="https://badgen.net/david/dep/async-library/react-async/packages/react-async" alt="dependencies">
56-
<img src="https://badgen.net/david/dev/async-library/react-async" alt="devDependencies">
57-
<img src="https://badgen.net/david/peer/async-library/react-async/packages/react-async" alt="peerDependencies">
58-
<br/>
5942
<a href="https://discord.gg/CAYQ6mU">
6043
<img src="https://img.shields.io/badge/discord-join-7289DA.svg?logo=discord&longCache=true&style=flat" />
6144
</a>
@@ -74,6 +57,7 @@ Use it with `fetch`, Axios or other data fetching libraries, even GraphQL.
7457

7558
- Zero dependencies
7659
- Works with promises, async/await and the Fetch API
60+
- Now with experimental Suspense support
7761
- Choose between Render Props, Context-based helper components or the `useAsync` and `useFetch` hooks
7862
- Debug and develop every part of the loading sequence with the React Async DevTools
7963
- Provides convenient `isPending`, `startedAt`, `finishedAt`, et al metadata
@@ -83,7 +67,7 @@ Use it with `fetch`, Axios or other data fetching libraries, even GraphQL.
8367
- Supports [abortable fetch] by providing an AbortController
8468
- Supports optimistic updates using `setData`
8569
- Supports server-side rendering through `initialValue`
86-
- Comes with type definitions for TypeScript
70+
- Written in TypeScript, ships with type definitions
8771
- Works well in React Native too!
8872

8973
[abortable fetch]: https://developers.google.com/web/updates/2017/09/abortable-fetch
@@ -111,6 +95,22 @@ Use it with `fetch`, Axios or other data fetching libraries, even GraphQL.
11195
- [State properties](https://docs.react-async.com/api/state)
11296
- [Helper components](https://docs.react-async.com/api/helpers)
11397

98+
## Guide
99+
100+
- [Async components](https://docs.react-async.com/guide/async-components)
101+
- [Separating view and logic](https://docs.react-async.com/guide/separating-view-logic)
102+
- [Async actions](https://docs.react-async.com/guide/async-actions)
103+
- [Optimistic updates](https://docs.react-async.com/guide/optimistic-updates)
104+
- [Server-side rendering](https://docs.react-async.com/guide/server-side-rendering)
105+
106+
## Contributing
107+
108+
- [Introduction](https://docs.react-async.com/contributing/introduction)
109+
- [Setting up](https://docs.react-async.com/contributing/setting-up)
110+
- [Development](https://docs.react-async.com/contributing/development)
111+
- [Testing](https://docs.react-async.com/contributing/testing)
112+
- [Releasing](https://docs.react-async.com/contributing/releasing)
113+
114114
# Contributors
115115

116116
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
@@ -147,9 +147,19 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
147147
</tr>
148148
<tr>
149149
<td align="center"><a href="https://munir.dev"><img src="https://avatars3.githubusercontent.com/u/5339664?v=4" width="75px;" alt="Munir Ahmed Elsangedy"/><br /><sub><b>Munir Ahmed Elsangedy</b></sub></a><br /><a href="#ideas-elsangedy" title="Ideas, Planning, & Feedback">🤔</a></td>
150+
<td align="center"><a href="https://github.com/AlixWang"><img src="https://avatars0.githubusercontent.com/u/5417459?v=4" width="75px;" alt="AlixWang"/><br /><sub><b>AlixWang</b></sub></a><br /><a href="https://github.com/async-library/react-async/commits?author=AlixWang" title="Documentation">📖</a></td>
151+
<td align="center"><a href="http://salolivares.com"><img src="https://avatars0.githubusercontent.com/u/1812749?v=4" width="75px;" alt="Sal Olivares"/><br /><sub><b>Sal Olivares</b></sub></a><br /><a href="https://github.com/async-library/react-async/commits?author=salolivares" title="Code">💻</a> <a href="https://github.com/async-library/react-async/issues?q=author%3Asalolivares" title="Bug reports">🐛</a></td>
150152
</tr>
151153
</table>
152154

153155
<!-- ALL-CONTRIBUTORS-LIST:END -->
154156

155157
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
158+
159+
## Similar projects
160+
161+
- [@slorber/react-async-hook](https://github.com/slorber/react-async-hook)
162+
- [@dai-shi/react-hooks-async](https://github.com/dai-shi/react-hooks-async)
163+
- [@cristovao-trevisan/async-resource](https://github.com/cristovao-trevisan/async-resource)
164+
- [@ilyalesik/react-fetch-hook](https://github.com/ilyalesik/react-fetch-hook)
165+
- [@marcin-piela/react-fetching-library](https://github.com/marcin-piela/react-fetching-library)

babel.config.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
module.exports = {
22
presets: ["@babel/preset-react"],
3-
plugins: ["@babel/plugin-proposal-object-rest-spread"],
3+
plugins: ["@babel/plugin-proposal-object-rest-spread", "@babel/plugin-proposal-class-properties"],
44

55
env: {
66
test: {
7-
presets: ["@babel/preset-env", "@babel/preset-react"],
8-
plugins: ["@babel/plugin-transform-runtime"],
7+
presets: ["@babel/preset-env", "@babel/preset-react", "@babel/preset-typescript"],
8+
plugins: ["@babel/plugin-transform-runtime", "@babel/plugin-proposal-class-properties"],
99
},
1010
},
1111
}

docs/_summary.md

+24-8
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,30 @@
44

55
## Getting started
66

7-
- [Installation](installation.md)
8-
- [Upgrading](upgrading.md)
9-
- [Usage](usage.md)
10-
- [DevTools](devtools.md)
7+
- [Installation](getting-started/installation.md)
8+
- [Upgrading](getting-started/upgrading.md)
9+
- [Usage](getting-started/usage.md)
10+
- [DevTools](getting-started/devtools.md)
1111

1212
## API
1313

14-
- [Interfaces](interfaces.md)
15-
- [Configuration options](options.md)
16-
- [State properties](state.md)
17-
- [Helper components](helpers.md)
14+
- [Interfaces](api/interfaces.md)
15+
- [Configuration options](api/options.md)
16+
- [State properties](api/state.md)
17+
- [Helper components](api/helpers.md)
18+
19+
## Guide
20+
21+
- [Async components](guide/async-components.md)
22+
- [Separating view and logic](guide/separating-view-logic.md)
23+
- [Async actions](guide/async-actions.md)
24+
- [Optimistic updates](guide/optimistic-updates.md)
25+
- [Server-side rendering](guide/server-side-rendering.md)
26+
27+
## Contributing
28+
29+
- [Introduction](contributing/introduction.md)
30+
- [Setting up](contributing/setting-up.md)
31+
- [Development](contributing/development.md)
32+
- [Testing](contributing/testing.md)
33+
- [Releasing](contributing/releasing.md)
File renamed without changes.

docs/interfaces.md docs/api/interfaces.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
React Async provides several ways to use it. The classic interface is through the `<Async>` component, which is
44
backwards compatible to React v16.3. More recent React applications will be using hooks, of which two are provided:
5-
`useAsync` and `useFetch`. Functionally, `<Async>` and `useAsync` are equivalent. `useFetch` is a special type of `useAsync` which is tied to the native `fetch` API.
5+
`useAsync` and `useFetch`. Functionally, `<Async>` and `useAsync` are equivalent. `useFetch` is a special version of
6+
`useAsync` which is tied to the native `fetch` API.
67

78
React Async accepts a wide range of [configuration options](options.md) and returns a set of [state props](state.md).
89
The way you use these differs slightly between the `useAsync` and `useFetch` hooks, and the `<Async>` component.
File renamed without changes.

docs/state.md docs/api/state.md

File renamed without changes.

docs/contributing/development.md

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Development
2+
3+
React Async is a library without visual parts. Only the DevTools have a user interface you can spin up in a browser.
4+
Therefore the development workflow for the core library might be different from what you're used to. Generally, we use a
5+
TDD approach:
6+
7+
- Write a unit test for the new feature or bug you want to fix. Sometimes you can just extend an existing test.
8+
- Fix the test by implementing the feature or bugfix. Now all tests should pass.
9+
- Optionally refactor the code for performance, readability and style. Probably this will come up during PR review.
10+
11+
We use the GitHub pull request workflow. In practice this means your workflow looks like this:
12+
13+
- Fork the repo (or pull the latest upstream) under your own account.
14+
- Make your changes, commit and push them. We don't enforce any commit message format.
15+
- Open a pull request on the main repository against the `next` branch. Make sure to follow the template.
16+
- We'll review your PR and will probably ask for some changes.
17+
- Once ready, we'll merge your PR.
18+
- Your changes will be in the next release.
19+
20+
## Working with Storybook
21+
22+
We use Storybook as a development environment for the DevTools. Spin it up using:
23+
24+
```sh
25+
yarn start:storybook
26+
```
27+
28+
This should open up Storybook in a browser at http://localhost:6006/
29+
Run it side-by-side with `yarn test --watch` during development. See [Testing](#testing).
30+
31+
## Working with the examples
32+
33+
In the `examples` folder, you will find sample React applications that use React Async in various ways with various other libraries. Please add a new example when introducing a major new feature. Make sure to add it to `now.json` so it is automatically deployed when merged to `master`.
34+
35+
To run sample examples on your local environments
36+
37+
```sh
38+
yarn build:examples
39+
yarn test:examples
40+
yarn start:examples
41+
```
42+
43+
## Resolving issues
44+
45+
Sometimes your dependencies might end up in a weird state, causing random issues, especially when working with the examples. In this case it often helps to run `yarn clean -y && yarn bootstrap`. This will delete `node_modules` from all packages/examples and do a clean install.

0 commit comments

Comments
 (0)