Skip to content

Commit

Permalink
Fix initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladislav committed Dec 16, 2022
1 parent 4282858 commit 14ba103
Show file tree
Hide file tree
Showing 7 changed files with 170 additions and 21 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/
5 changes: 5 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,9 @@ module.exports = {
}],
'@typescript-eslint/semi': ['error', 'always'],
},
settings: {
react: {
version: '16.8.0',
},
},
};
1 change: 0 additions & 1 deletion .npmignore

This file was deleted.

17 changes: 13 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
{
"name": "react-odometerjs",
"version": "3.0.0",
"version": "3.0.1",
"description": "Odometer.js as a React component",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist/",
"LICENSE.MD",
"README.MD"
],
"repository": {
"type": "git",
"url": "git+https://github.com/inferusvv/react-odometerjs.git"
Expand All @@ -11,10 +17,12 @@
"react",
"component",
"odometer",
"hubspot",
"js",
"react-component",
"javascript",
"hubspot"
"typescript",
"counter"
],
"author": "Vladislav Bezenson",
"license": "MIT",
Expand All @@ -35,14 +43,15 @@
"@typescript-eslint/parser": "^5.46.1",
"eslint": "^8.0.1",
"eslint-config-standard-with-typescript": "latest",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-n": "^15.0.0",
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-react": "latest",
"typescript": "*"
},
"scripts": {
"build": "tsc",
"lint-js": "eslint --ignore-path .gitignore --ignore-pattern \"!**/.*\" .",
"build": "rm -rf dist/ && tsc",
"lint": "eslint .",
"prepublish": "npm run build"
},
"packageManager": "[email protected]"
Expand Down
14 changes: 8 additions & 6 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,20 @@ export interface ReactOdometerProps {
}

const ReactOdometer: FC<ReactOdometerProps> = ({ value, ...options }) => {
const node = useRef();
const odometer = useRef(
new Odometer({
const node = useRef<HTMLDivElement>(null);
const odometer = useRef<Odometer>();

useEffect(() => {
odometer.current = new Odometer({
el: node.current,
auto: false,
value,
...options,
}),
);
});
}, []);

useEffect(() => {
odometer.current.update(value);
odometer.current?.update(value);
}, [value]);

return createElement('div', {
Expand Down
5 changes: 2 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{
"compilerOptions": {
"target": "esnext",
"module": "commonjs",
"target": "ESNext",
"declaration": true,
"outDir": "./dist",
"strict": true,
"skipLibCheck": true
},
"include": ["src", "odometer.d.ts"],
"include": ["src/", "odometer.d.ts"],
"exclude": ["node_modules"],
}
148 changes: 141 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ __metadata:
languageName: node
linkType: hard

"@types/json5@npm:^0.0.29":
version: 0.0.29
resolution: "@types/json5@npm:0.0.29"
checksum: e60b153664572116dfea673c5bda7778dbff150498f44f998e34b5886d8afc47f16799280e4b6e241c0472aef1bc36add771c569c68fc5125fc2ae519a3eb9ac
languageName: node
linkType: hard

"@types/prop-types@npm:*":
version: 15.7.5
resolution: "@types/prop-types@npm:15.7.5"
Expand Down Expand Up @@ -286,7 +293,7 @@ __metadata:
languageName: node
linkType: hard

"array-includes@npm:^3.1.5, array-includes@npm:^3.1.6":
"array-includes@npm:^3.1.4, array-includes@npm:^3.1.5, array-includes@npm:^3.1.6":
version: 3.1.6
resolution: "array-includes@npm:3.1.6"
dependencies:
Expand All @@ -306,6 +313,18 @@ __metadata:
languageName: node
linkType: hard

"array.prototype.flat@npm:^1.2.5":
version: 1.3.1
resolution: "array.prototype.flat@npm:1.3.1"
dependencies:
call-bind: ^1.0.2
define-properties: ^1.1.4
es-abstract: ^1.20.4
es-shim-unscopables: ^1.0.0
checksum: 5a8415949df79bf6e01afd7e8839bbde5a3581300e8ad5d8449dea52639e9e59b26a467665622783697917b43bf39940a6e621877c7dd9b3d1c1f97484b9b88b
languageName: node
linkType: hard

"array.prototype.flatmap@npm:^1.3.1":
version: 1.3.1
resolution: "array.prototype.flatmap@npm:1.3.1"
Expand Down Expand Up @@ -434,6 +453,24 @@ __metadata:
languageName: node
linkType: hard

"debug@npm:^2.6.9":
version: 2.6.9
resolution: "debug@npm:2.6.9"
dependencies:
ms: 2.0.0
checksum: d2f51589ca66df60bf36e1fa6e4386b318c3f1e06772280eea5b1ae9fd3d05e9c2b7fd8a7d862457d00853c75b00451aa2d7459b924629ee385287a650f58fe6
languageName: node
linkType: hard

"debug@npm:^3.2.7":
version: 3.2.7
resolution: "debug@npm:3.2.7"
dependencies:
ms: ^2.1.1
checksum: b3d8c5940799914d30314b7c3304a43305fd0715581a919dacb8b3176d024a782062368405b47491516d2091d6462d4d11f2f4974a405048094f8bfebfa3071c
languageName: node
linkType: hard

"debug@npm:^4.1.1, debug@npm:^4.3.2, debug@npm:^4.3.4":
version: 4.3.4
resolution: "debug@npm:4.3.4"
Expand Down Expand Up @@ -579,6 +616,28 @@ __metadata:
languageName: node
linkType: hard

"eslint-import-resolver-node@npm:^0.3.6":
version: 0.3.6
resolution: "eslint-import-resolver-node@npm:0.3.6"
dependencies:
debug: ^3.2.7
resolve: ^1.20.0
checksum: 6266733af1e112970e855a5bcc2d2058fb5ae16ad2a6d400705a86b29552b36131ffc5581b744c23d550de844206fb55e9193691619ee4dbf225c4bde526b1c8
languageName: node
linkType: hard

"eslint-module-utils@npm:^2.7.3":
version: 2.7.4
resolution: "eslint-module-utils@npm:2.7.4"
dependencies:
debug: ^3.2.7
peerDependenciesMeta:
eslint:
optional: true
checksum: 5da13645daff145a5c922896b258f8bba560722c3767254e458d894ff5fbb505d6dfd945bffa932a5b0ae06714da2379bd41011c4c20d2d59cc83e23895360f7
languageName: node
linkType: hard

"eslint-plugin-es@npm:^4.1.0":
version: 4.1.0
resolution: "eslint-plugin-es@npm:4.1.0"
Expand All @@ -591,6 +650,29 @@ __metadata:
languageName: node
linkType: hard

"eslint-plugin-import@npm:^2.26.0":
version: 2.26.0
resolution: "eslint-plugin-import@npm:2.26.0"
dependencies:
array-includes: ^3.1.4
array.prototype.flat: ^1.2.5
debug: ^2.6.9
doctrine: ^2.1.0
eslint-import-resolver-node: ^0.3.6
eslint-module-utils: ^2.7.3
has: ^1.0.3
is-core-module: ^2.8.1
is-glob: ^4.0.3
minimatch: ^3.1.2
object.values: ^1.1.5
resolve: ^1.22.0
tsconfig-paths: ^3.14.1
peerDependencies:
eslint: ^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8
checksum: 0bf77ad80339554481eafa2b1967449e1f816b94c7a6f9614ce33fb4083c4e6c050f10d241dd50b4975d47922880a34de1e42ea9d8e6fd663ebb768baa67e655
languageName: node
linkType: hard

"eslint-plugin-n@npm:^15.0.0":
version: 15.6.0
resolution: "eslint-plugin-n@npm:15.6.0"
Expand Down Expand Up @@ -1142,7 +1224,7 @@ __metadata:
languageName: node
linkType: hard

"is-core-module@npm:^2.11.0, is-core-module@npm:^2.9.0":
"is-core-module@npm:^2.11.0, is-core-module@npm:^2.8.1, is-core-module@npm:^2.9.0":
version: 2.11.0
resolution: "is-core-module@npm:2.11.0"
dependencies:
Expand Down Expand Up @@ -1296,6 +1378,17 @@ __metadata:
languageName: node
linkType: hard

"json5@npm:^1.0.1":
version: 1.0.1
resolution: "json5@npm:1.0.1"
dependencies:
minimist: ^1.2.0
bin:
json5: lib/cli.js
checksum: e76ea23dbb8fc1348c143da628134a98adf4c5a4e8ea2adaa74a80c455fc2cdf0e2e13e6398ef819bfe92306b610ebb2002668ed9fc1af386d593691ef346fc3
languageName: node
linkType: hard

"jsx-ast-utils@npm:^2.4.1 || ^3.0.0":
version: 3.3.3
resolution: "jsx-ast-utils@npm:3.3.3"
Expand Down Expand Up @@ -1378,13 +1471,34 @@ __metadata:
languageName: node
linkType: hard

"minimist@npm:^1.2.0, minimist@npm:^1.2.6":
version: 1.2.7
resolution: "minimist@npm:1.2.7"
checksum: 7346574a1038ca23c32e02252f603801f09384dd1d78b69a943a4e8c2c28730b80e96193882d3d3b22a063445f460e48316b29b8a25addca2d7e5e8f75478bec
languageName: node
linkType: hard

"ms@npm:2.0.0":
version: 2.0.0
resolution: "ms@npm:2.0.0"
checksum: 0e6a22b8b746d2e0b65a430519934fefd41b6db0682e3477c10f60c76e947c4c0ad06f63ffdf1d78d335f83edee8c0aa928aa66a36c7cd95b69b26f468d527f4
languageName: node
linkType: hard

"ms@npm:2.1.2":
version: 2.1.2
resolution: "ms@npm:2.1.2"
checksum: 673cdb2c3133eb050c745908d8ce632ed2c02d85640e2edb3ace856a2266a813b30c613569bf3354fdf4ea7d1a1494add3bfa95e2713baa27d0c2c71fc44f58f
languageName: node
linkType: hard

"ms@npm:^2.1.1":
version: 2.1.3
resolution: "ms@npm:2.1.3"
checksum: aa92de608021b242401676e35cfa5aa42dd70cbdc082b916da7fb925c542173e36bce97ea3e804923fe92c0ad991434e4a38327e15a1b5b5f945d66df615ae6d
languageName: node
linkType: hard

"natural-compare-lite@npm:^1.4.0":
version: 1.4.0
resolution: "natural-compare-lite@npm:1.4.0"
Expand Down Expand Up @@ -1464,7 +1578,7 @@ __metadata:
languageName: node
linkType: hard

"object.values@npm:^1.1.6":
"object.values@npm:^1.1.5, object.values@npm:^1.1.6":
version: 1.1.6
resolution: "object.values@npm:1.1.6"
dependencies:
Expand Down Expand Up @@ -1622,14 +1736,15 @@ __metadata:
"@typescript-eslint/parser": ^5.46.1
eslint: ^8.0.1
eslint-config-standard-with-typescript: latest
eslint-plugin-import: ^2.26.0
eslint-plugin-n: ^15.0.0
eslint-plugin-promise: ^6.0.0
eslint-plugin-react: latest
odometer: ^0.4.8
typescript: "*"
peerDependencies:
react: ">= 16.3.0"
react-dom: ">= 16.3.0"
react: ">= 16.8.0"
react-dom: ">= 16.8.0"
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -1658,7 +1773,7 @@ __metadata:
languageName: node
linkType: hard

"resolve@npm:^1.22.1":
"resolve@npm:^1.20.0, resolve@npm:^1.22.0, resolve@npm:^1.22.1":
version: 1.22.1
resolution: "resolve@npm:1.22.1"
dependencies:
Expand All @@ -1684,7 +1799,7 @@ __metadata:
languageName: node
linkType: hard

"resolve@patch:resolve@^1.22.1#~builtin<compat/resolve>":
"resolve@patch:resolve@^1.20.0#~builtin<compat/resolve>, resolve@patch:resolve@^1.22.0#~builtin<compat/resolve>, resolve@patch:resolve@^1.22.1#~builtin<compat/resolve>":
version: 1.22.1
resolution: "resolve@patch:resolve@npm%3A1.22.1#~builtin<compat/resolve>::version=1.22.1&hash=c3c19d"
dependencies:
Expand Down Expand Up @@ -1849,6 +1964,13 @@ __metadata:
languageName: node
linkType: hard

"strip-bom@npm:^3.0.0":
version: 3.0.0
resolution: "strip-bom@npm:3.0.0"
checksum: 8d50ff27b7ebe5ecc78f1fe1e00fcdff7af014e73cf724b46fb81ef889eeb1015fc5184b64e81a2efe002180f3ba431bdd77e300da5c6685d702780fbf0c8d5b
languageName: node
linkType: hard

"strip-json-comments@npm:^3.1.0, strip-json-comments@npm:^3.1.1":
version: 3.1.1
resolution: "strip-json-comments@npm:3.1.1"
Expand Down Expand Up @@ -1888,6 +2010,18 @@ __metadata:
languageName: node
linkType: hard

"tsconfig-paths@npm:^3.14.1":
version: 3.14.1
resolution: "tsconfig-paths@npm:3.14.1"
dependencies:
"@types/json5": ^0.0.29
json5: ^1.0.1
minimist: ^1.2.6
strip-bom: ^3.0.0
checksum: 8afa01c673ebb4782ba53d3a12df97fa837ce524f8ad38ee4e2b2fd57f5ac79abc21c574e9e9eb014d93efe7fe8214001b96233b5c6ea75bd1ea82afe17a4c6d
languageName: node
linkType: hard

"tslib@npm:^1.8.1":
version: 1.14.1
resolution: "tslib@npm:1.14.1"
Expand Down

0 comments on commit 14ba103

Please sign in to comment.