Skip to content
This repository was archived by the owner on Aug 3, 2023. It is now read-only.

Commit a1fe60b

Browse files
authored
Merge pull request #186 from jamesplease/updates
Updates
2 parents aab1dfa + 8ab63d9 commit a1fe60b

File tree

14 files changed

+176
-151
lines changed

14 files changed

+176
-151
lines changed

.babelrc

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,43 @@
11
{
22
"env": {
33
"build": {
4-
"presets": [["env", { "modules": false }], "stage-3", "react"],
4+
"presets": [
5+
["env", {
6+
"modules": false
7+
}], "stage-3", "react"
8+
],
59
"plugins": ["external-helpers", "transform-class-properties"]
610
},
711
"buildProd": {
8-
"presets": [["env", { "modules": false }], "stage-3", "react"],
12+
"presets": [
13+
["env", {
14+
"modules": false
15+
}], "stage-3", "react"
16+
],
917
"plugins": [
1018
"external-helpers",
11-
"transform-class-properties",
12-
[
19+
"transform-class-properties", [
1320
"transform-react-remove-prop-types",
14-
{ "mode": "remove", "removeImport": true }
21+
{
22+
"mode": "remove",
23+
"removeImport": true
24+
}
1525
]
1626
]
1727
},
1828
"es": {
19-
"presets": [["env", { "modules": false }], "stage-3", "react"],
29+
"presets": [
30+
["env", {
31+
"modules": false
32+
}], "stage-3", "react"
33+
],
2034
"plugins": ["transform-class-properties"]
2135
},
2236
"commonjs": {
2337
"plugins": [
24-
["transform-es2015-modules-commonjs", { "loose": true }],
38+
["transform-es2015-modules-commonjs", {
39+
"loose": true
40+
}],
2541
"transform-class-properties"
2642
],
2743
"presets": ["stage-3", "react"]
@@ -31,4 +47,4 @@
3147
"plugins": ["transform-class-properties"]
3248
}
3349
}
34-
}
50+
}

.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@
2222
"Promise": true
2323
},
2424
"plugins": ["react"]
25-
}
25+
}

.prettierrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"singleQuote": true,
33
"jsxBracketSameLine": true,
44
"trailingComma": "es5"
5-
}
5+
}

examples/fetch-components/src/App.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class App extends Component {
1212
components={[
1313
<ReadPost postId="1" />,
1414
<UpdatePost postId="1" />,
15-
<DeletePost postId="1" />
15+
<DeletePost postId="1" />,
1616
]}>
1717
{([readPost, updatePost, deletePost]) => (
1818
<div>
@@ -30,8 +30,8 @@ class App extends Component {
3030
onClick={() =>
3131
updatePost.doFetch({
3232
body: JSON.stringify({
33-
title: 'hello'
34-
})
33+
title: 'hello',
34+
}),
3535
})
3636
}
3737
disabled={

examples/multiple-requests/src/App.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class App extends Component {
1212
<Fetch
1313
url="https://jsonplaceholder.typicode.com/posts/1"
1414
method="delete"
15-
/>
15+
/>,
1616
]}>
1717
{([readPostOne, readPostTwo, deletePostOne]) => (
1818
<div>

examples/response-caching/src/App.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ class App extends Component {
3434
}
3535

3636
state = {
37-
fetchAgain: false
37+
fetchAgain: false,
3838
};
3939

4040
componentDidMount() {
4141
setTimeout(() => {
4242
this.setState({
43-
fetchAgain: true
43+
fetchAgain: true,
4444
});
4545
}, 2000);
4646
}

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ module.exports = {
22
collectCoverage: true,
33
collectCoverageFrom: ['src/**/*.{js,jsx}', '!**/node_modules/**'],
44
coverageDirectory: 'coverage',
5-
setupTestFrameworkScriptFile: './test/setup.js'
5+
setupTestFrameworkScriptFile: './test/setup.js',
66
};

rollup.config.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,27 @@ var config = {
1010
moduleName: 'ReactRequest',
1111
external: ['react'],
1212
globals: {
13-
react: 'React'
13+
react: 'React',
1414
},
1515
context: 'this',
1616
plugins: [
1717
nodeResolve({
18-
jsnext: true
18+
jsnext: true,
1919
}),
2020
commonjs({
21-
include: 'node_modules/**'
21+
include: 'node_modules/**',
2222

2323
// explicitly specify unresolvable named exports
2424
// (see below for more details)
2525
// namedExports: { './module.js': ['foo', 'bar' ] }, // Default: undefined
2626
}),
2727
babel({
28-
exclude: 'node_modules/**'
28+
exclude: 'node_modules/**',
2929
}),
3030
replace({
31-
'process.env.NODE_ENV': JSON.stringify(env)
32-
})
33-
]
31+
'process.env.NODE_ENV': JSON.stringify(env),
32+
}),
33+
],
3434
};
3535

3636
if (env === 'production') {
@@ -40,8 +40,8 @@ if (env === 'production') {
4040
pure_getters: true,
4141
unsafe: true,
4242
unsafe_comps: true,
43-
warnings: false
44-
}
43+
warnings: false,
44+
},
4545
})
4646
);
4747
}

src/fetch.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -150,18 +150,13 @@ export class Fetch extends React.Component {
150150
};
151151

152152
fetchRenderProp = options => {
153-
// Heads up! This can _never_ be synchronous, as it causes the component to
154-
// render, and a user may call it synchronously within the children function.
155-
//
156-
// tl;dr, the following code should never cause a React warning or error:
157-
//
158-
// `<Fetch children={({ doFetch }) => doFetch()} />
159153
return new Promise(resolve => {
160-
// We originally wrapped this in a setTimeout so as to avoid calls to `setState`
154+
// We wrap this in a setTimeout so as to avoid calls to `setState`
161155
// in render, which React does not allow.
162-
// However, with the recent refactor to return a Promise, the `setTimeout` is not
163-
// strictly necessary. At this time, the testing setup requires the timeout remain,
164-
// but it will be refactored at a future time.
156+
//
157+
// tl;dr, the following code should never cause a React warning or error:
158+
//
159+
// `<Fetch children={({ doFetch }) => doFetch()} />
165160
setTimeout(() => {
166161
this.fetchData(options, true, resolve);
167162
});

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
fetchDedupe,
44
getRequestKey,
55
clearRequestCache,
6-
isRequestInFlight
6+
isRequestInFlight,
77
} from 'fetch-dedupe';
88

99
export {
@@ -12,5 +12,5 @@ export {
1212
getRequestKey,
1313
isRequestInFlight,
1414
clearRequestCache,
15-
clearResponseCache
15+
clearResponseCache,
1616
};

0 commit comments

Comments
 (0)