Skip to content

Commit 0b77230

Browse files
authored
Merge pull request #71 from Lemoncode/bug/fix-hoc-delay-issue
Bug/fix hoc delay issue
2 parents 2f16687 + 4370454 commit 0b77230

File tree

3 files changed

+230
-126
lines changed

3 files changed

+230
-126
lines changed

package.json

Lines changed: 102 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,102 @@
1-
{
2-
"name": "react-promise-tracker",
3-
"version": "2.0.3",
4-
"description": "Simple React Promise tracker Hook/HOC helper to add loading spinner indicators",
5-
"keywords": [
6-
"react",
7-
"promise",
8-
"tracker",
9-
"track",
10-
"hook",
11-
"hoc",
12-
"higher order component",
13-
"spinner",
14-
"component"
15-
],
16-
"homepage": "https://github.com/Lemoncode/react-promise-tracker#readme",
17-
"bugs": {
18-
"url": "https://github.com/Lemoncode/react-promise-tracker/issues"
19-
},
20-
"license": "MIT",
21-
"author": "Lemoncode",
22-
"contributors": [
23-
"Braulio Diez <[email protected]> (https://github.com/brauliodiez)",
24-
"Javier Calzado <[email protected] > (https://github.com/fjcalzado)",
25-
"Daniel Sanchez <[email protected]> (https://github.com/nasdan)",
26-
"Alejandro Rosa <> (https://github.com/arp82)"
27-
],
28-
"files": [
29-
"dist",
30-
"es",
31-
"lib",
32-
"index.d.ts",
33-
"LICENSE.txt",
34-
"package.json",
35-
"readme.md"
36-
],
37-
"browser": "lib/index.js",
38-
"main": "lib/index.js",
39-
"types": "index.d.ts",
40-
"module": "es/index.js",
41-
"jsnext:main": "es/index.js",
42-
"repository": {
43-
"type": "git",
44-
"url": "git+https://github.com/Lemoncode/react-promise-tracker.git"
45-
},
46-
"scripts": {
47-
"clean": "rimraf build/*",
48-
"build": "npm run clean && npm run build:lib && npm run build:es && npm run build:dist:prod && npm run build:copy",
49-
"build:lib": "cross-env BABEL_ENV=es5_cjs babel src --out-dir build/lib --ignore 'src/**/*.spec.js,src/**/*.test.js'",
50-
"build:es": "cross-env BABEL_ENV=es babel src --out-dir build/es --ignore 'src/**/*.spec.js,src/**/*.test.js'",
51-
"build:dist:prod": "cross-env BABEL_ENV=umd webpack -p --config ./config/webpack/webpack.prod.js",
52-
"build:dist:dev": "cross-env BABEL_ENV=umd webpack --config ./config/webpack/webpack.dev.js",
53-
"build:copy": "copyfiles package.json readme.md LICENSE.txt build && copyfiles \"./src/**/*.d.ts\" -u 1 build",
54-
"test": "cross-env NODE_ENV=test jest",
55-
"test:watch": "cross-env NODE_ENV=test jest --watchAll",
56-
"release:prepare": "npm run clean && npm run test && npm run build && rimraf build/dist/report",
57-
"release": "npm publish ./build",
58-
"release-beta": "npm run release:prepare && npm publish ./build --tag beta"
59-
},
60-
"peerDependencies": {
61-
"react": ">=16.8.0"
62-
},
63-
"dependencies": {},
64-
"devDependencies": {
65-
"@babel/cli": "^7.2.3",
66-
"@babel/core": "^7.2.2",
67-
"@babel/preset-env": "^7.3.1",
68-
"@babel/preset-react": "^7.0.0",
69-
"@babel/register": "^7.0.0",
70-
"babel-loader": "^8.0.5",
71-
"compression-webpack-plugin": "^2.0.0",
72-
"copyfiles": "^2.1.0",
73-
"cross-env": "^5.2.0",
74-
"enzyme": "^3.9.0",
75-
"enzyme-adapter-react-16": "^1.11.2",
76-
"enzyme-to-json": "^3.3.5",
77-
"jest": "^24.5.0",
78-
"raf": "^3.4.1",
79-
"react": "^16.8.5",
80-
"react-dom": "^16.8.5",
81-
"react-test-renderer": "^16.8.4",
82-
"regenerator-runtime": "^0.13.1",
83-
"rimraf": "^2.6.3",
84-
"webpack": "^4.29.6",
85-
"webpack-bundle-analyzer": "^3.1.0",
86-
"webpack-cli": "^3.3.0",
87-
"webpack-merge": "^4.2.1"
88-
},
89-
"jest": {
90-
"setupFiles": [
91-
"./config/test/polyfills.js",
92-
"./config/test/setupJest.js"
93-
],
94-
"snapshotSerializers": [
95-
"enzyme-to-json/serializer"
96-
],
97-
"restoreMocks": true,
98-
"testPathIgnorePatterns": [
99-
"/node_modules/"
100-
]
101-
}
102-
}
1+
{
2+
"name": "react-promise-tracker",
3+
"version": "2.0.4",
4+
"description": "Simple React Promise tracker Hook/HOC helper to add loading spinner indicators",
5+
"keywords": [
6+
"react",
7+
"promise",
8+
"tracker",
9+
"track",
10+
"hook",
11+
"hoc",
12+
"higher order component",
13+
"spinner",
14+
"component"
15+
],
16+
"homepage": "https://github.com/Lemoncode/react-promise-tracker#readme",
17+
"bugs": {
18+
"url": "https://github.com/Lemoncode/react-promise-tracker/issues"
19+
},
20+
"license": "MIT",
21+
"author": "Lemoncode",
22+
"contributors": [
23+
"Braulio Diez <[email protected]> (https://github.com/brauliodiez)",
24+
"Javier Calzado <[email protected] > (https://github.com/fjcalzado)",
25+
"Daniel Sanchez <[email protected]> (https://github.com/nasdan)",
26+
"Alejandro Rosa <> (https://github.com/arp82)"
27+
],
28+
"files": [
29+
"dist",
30+
"es",
31+
"lib",
32+
"index.d.ts",
33+
"LICENSE.txt",
34+
"package.json",
35+
"readme.md"
36+
],
37+
"browser": "lib/index.js",
38+
"main": "lib/index.js",
39+
"types": "index.d.ts",
40+
"module": "es/index.js",
41+
"jsnext:main": "es/index.js",
42+
"repository": {
43+
"type": "git",
44+
"url": "git+https://github.com/Lemoncode/react-promise-tracker.git"
45+
},
46+
"scripts": {
47+
"clean": "rimraf build/*",
48+
"build": "npm run clean && npm run build:lib && npm run build:es && npm run build:dist:prod && npm run build:copy",
49+
"build:lib": "cross-env BABEL_ENV=es5_cjs babel src --out-dir build/lib --ignore 'src/**/*.spec.js,src/**/*.test.js'",
50+
"build:es": "cross-env BABEL_ENV=es babel src --out-dir build/es --ignore 'src/**/*.spec.js,src/**/*.test.js'",
51+
"build:dist:prod": "cross-env BABEL_ENV=umd webpack -p --config ./config/webpack/webpack.prod.js",
52+
"build:dist:dev": "cross-env BABEL_ENV=umd webpack --config ./config/webpack/webpack.dev.js",
53+
"build:copy": "copyfiles package.json readme.md LICENSE.txt build && copyfiles \"./src/**/*.d.ts\" -u 1 build",
54+
"test": "cross-env NODE_ENV=test jest",
55+
"test:watch": "cross-env NODE_ENV=test jest --watchAll",
56+
"release:prepare": "npm run clean && npm run test && npm run build && rimraf build/dist/report",
57+
"release": "npm publish ./build",
58+
"release-beta": "npm run release:prepare && npm publish ./build --tag beta"
59+
},
60+
"peerDependencies": {
61+
"react": ">=16.8.0"
62+
},
63+
"dependencies": {},
64+
"devDependencies": {
65+
"@babel/cli": "^7.2.3",
66+
"@babel/core": "^7.2.2",
67+
"@babel/preset-env": "^7.3.1",
68+
"@babel/preset-react": "^7.0.0",
69+
"@babel/register": "^7.0.0",
70+
"babel-loader": "^8.0.5",
71+
"compression-webpack-plugin": "^2.0.0",
72+
"copyfiles": "^2.1.0",
73+
"cross-env": "^5.2.0",
74+
"enzyme": "^3.9.0",
75+
"enzyme-adapter-react-16": "^1.11.2",
76+
"enzyme-to-json": "^3.3.5",
77+
"jest": "^24.5.0",
78+
"raf": "^3.4.1",
79+
"react": "^16.8.5",
80+
"react-dom": "^16.8.5",
81+
"react-test-renderer": "^16.8.4",
82+
"regenerator-runtime": "^0.13.1",
83+
"rimraf": "^2.6.3",
84+
"webpack": "^4.29.6",
85+
"webpack-bundle-analyzer": "^3.1.0",
86+
"webpack-cli": "^3.3.0",
87+
"webpack-merge": "^4.2.1"
88+
},
89+
"jest": {
90+
"setupFiles": [
91+
"./config/test/polyfills.js",
92+
"./config/test/setupJest.js"
93+
],
94+
"snapshotSerializers": [
95+
"enzyme-to-json/serializer"
96+
],
97+
"restoreMocks": true,
98+
"testPathIgnorePatterns": [
99+
"/node_modules/"
100+
]
101+
}
102+
}

src/trackerHoc.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { Component } from 'react';
22
import {
33
emitter,
44
getCounter,
5-
promiseCounterUpdateEventId
5+
promiseCounterUpdateEventId,
66
} from './trackPromise';
77
import { setupConfig } from './setupConfig';
88

@@ -20,7 +20,7 @@ export const promiseTrackerHoc = ComponentToWrap => {
2020
this.state = {
2121
promiseInProgress: false,
2222
internalPromiseInProgress: false,
23-
config: setupConfig(props.config)
23+
config: setupConfig(props.config),
2424
};
2525

2626
this.notifyPromiseInProgress = this.notifyPromiseInProgress.bind(this);
@@ -32,7 +32,8 @@ export const promiseTrackerHoc = ComponentToWrap => {
3232
this.state.config.delay === 0
3333
? this.setState({ promiseInProgress: true })
3434
: setTimeout(() => {
35-
this.setState({ promiseInProgress: true });
35+
const progress = Boolean(getCounter(this.state.config.area) > 0);
36+
this.setState({ promiseInProgress: progress });
3637
}, this.state.config.delay);
3738
}
3839

0 commit comments

Comments
 (0)