55 | Open the console to view output
56 |
57 | Render count:
58 |
59 | {isStable ? (
60 | setIsStable(!isStable)}>
61 | Stable button 😁
62 |
63 | ) : (
64 | setIsStable(!isStable)}>
65 | Unstable button 😵
66 |
67 | )}
68 |
69 | );
70 | });
71 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-stable-ref",
3 | "version": "0.5.2",
4 | "description": "An assortment of utilities for testing against unstable references in React",
5 | "main": "lib/index.js",
6 | "author": "Daniel Del Core",
7 | "license": "MIT",
8 | "typings": "lib/index.d.ts",
9 | "files": [
10 | "lib"
11 | ],
12 | "scripts": {
13 | "start": "npm run dev",
14 | "dev": "start-storybook -p 9000 -c .storybook -s ./assets",
15 | "predeploy-storybook": "build-storybook -s assets",
16 | "deploy-storybook": "storybook-to-ghpages",
17 | "build": "tsc",
18 | "typecheck": "tsc --noEmit",
19 | "test": "jest",
20 | "test:watch": "jest --watch",
21 | "test:coverage": "jest --coverage",
22 | "lint": "eslint --config .eslintrc.js --ext tsx,ts ./src/ ./examples ",
23 | "lint:fix": "npm run lint -- --fix",
24 | "preversion": "npm run lint && npm run typecheck && npm run test",
25 | "version": "npm run build",
26 | "postversion": "git push && git push --tags",
27 | "postpublish": "npm run deploy-storybook"
28 | },
29 | "homepage": "https://github.com/danieldelcore/react-stable-ref#readme",
30 | "repository": {
31 | "type": "git",
32 | "url": "git+https://github.com/danieldelcore/react-stable-ref.git"
33 | },
34 | "keywords": [
35 | "react",
36 | "hooks",
37 | "hook",
38 | "useRef",
39 | "useMemo"
40 | ],
41 | "bugs": {
42 | "url": "https://github.com/danieldelcore/react-stable-ref/issues"
43 | },
44 | "devDependencies": {
45 | "@babel/core": "^7.7.5",
46 | "@storybook/addon-storysource": "^5.2.8",
47 | "@storybook/addons": "^5.2.8",
48 | "@storybook/react": "^5.2.8",
49 | "@storybook/source-loader": "^5.2.8",
50 | "@storybook/storybook-deployer": "^2.8.1",
51 | "@testing-library/react": "^8.0.5",
52 | "@types/jest": "^23.3.13",
53 | "@types/jsdom": "^12.2.3",
54 | "@types/react": "^16.8.1",
55 | "@types/react-dom": "^16.8.2",
56 | "@types/storybook__react": "^4.0.0",
57 | "@typescript-eslint/eslint-plugin": "^1.4.2",
58 | "@typescript-eslint/parser": "^1.4.2",
59 | "babel-loader": "^8.0.6",
60 | "eslint": "^5.15.1",
61 | "eslint-config-prettier": "^4.1.0",
62 | "eslint-plugin-prettier": "^3.0.1",
63 | "eslint-plugin-react": "^7.12.4",
64 | "eslint-plugin-react-hooks": "^1.5.0",
65 | "jest": "^24.0.0",
66 | "jest-serializer-html-string": "^1.0.1",
67 | "jest-watch-typeahead": "^0.4.2",
68 | "jsdom": "^14.0.0",
69 | "prettier": "^1.16.4",
70 | "react": "^16.8.1",
71 | "react-dom": "^16.8.4",
72 | "react-test-renderer": "^16.13.0",
73 | "ts-jest": "^24.0.2",
74 | "ts-loader": "^6.2.1",
75 | "typescript": "^3.3.1"
76 | },
77 | "peerDependencies": {
78 | "react": ">=16.8.0"
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/src/useWhichDepChanged.spec.tsx:
--------------------------------------------------------------------------------
1 | import React, { FC, ReactNode } from 'react';
2 | import { render, cleanup } from '@testing-library/react';
3 |
4 | import useWhichDepChanged from './useWhichDepChanged';
5 |
6 | interface ButtonProps {
7 | data: any;
8 | children: ReactNode;
9 | onChange?: (changedDeps: Record