@whatitbroke/react 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +97 -0
- package/package.json +13 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 WhatItBroke Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# @whatitbroke/react
|
|
2
|
+
|
|
3
|
+
> **React Adapter, Error Boundary, Component Render Path Tracer, and Hook Rules Analyzer**
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@whatitbroke/react)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
`@whatitbroke/react` provides seamless error capture and root-cause analysis for React 18 & 19 applications, including component render hierarchy reconstruction and conditional hook violation detection.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install @whatitbroke/react @whatitbroke/core @whatitbroke/shared
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Features
|
|
21
|
+
|
|
22
|
+
* **`<WhatItBrokeBoundary>`**: Drop-in React Error Boundary component with customizable fallback UI and interactive developer overlay.
|
|
23
|
+
* **Component Render Path**: Parses React's `componentStack` into a chronological root-to-leaf path (e.g. `App ──► Dashboard ──► UserProfile`).
|
|
24
|
+
* **Hook Rules Detector**: Statically diagnoses conditional `useState`/`useEffect` calls, hook count mismatches, and missing dependency arrays.
|
|
25
|
+
* **Async Race Detection**: Detects when components attempt to render data before asynchronous `useQuery` or `fetch` calls have completed.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
### 1. Wrap Your Application with `<WhatItBrokeBoundary>`
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
import React from 'react';
|
|
35
|
+
import ReactDOM from 'react-dom/client';
|
|
36
|
+
import { WhatItBrokeBoundary } from '@whatitbroke/react';
|
|
37
|
+
import App from './App';
|
|
38
|
+
|
|
39
|
+
ReactDOM.createRoot(document.getElementById('root')!).render(
|
|
40
|
+
<React.StrictMode>
|
|
41
|
+
<WhatItBrokeBoundary
|
|
42
|
+
showOverlay={process.env.NODE_ENV === 'development'}
|
|
43
|
+
fallback={<div>An unexpected error occurred. Our team has been notified.</div>}
|
|
44
|
+
onError={(report) => {
|
|
45
|
+
console.error('WhatItBroke Report:', report);
|
|
46
|
+
}}
|
|
47
|
+
>
|
|
48
|
+
<App />
|
|
49
|
+
</WhatItBrokeBoundary>
|
|
50
|
+
</React.StrictMode>
|
|
51
|
+
);
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
### 2. Hook Rules Violation Detection
|
|
57
|
+
When React throws `Rendered fewer hooks than expected`, WhatItBroke isolates the exact conditional branch causing the discrepancy:
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
// ❌ Dangerous: Hooks inside conditions
|
|
61
|
+
function Profile({ user }) {
|
|
62
|
+
if (!user) return <Loading />;
|
|
63
|
+
|
|
64
|
+
// WhatItBroke detects this conditional hook violation and provides the fix!
|
|
65
|
+
const [data, setData] = useState(null);
|
|
66
|
+
...
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
### 3. Programmatic React Adapter
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
import { ReactAdapter } from '@whatitbroke/react';
|
|
76
|
+
import { WhatItBrokeCore } from '@whatitbroke/core';
|
|
77
|
+
|
|
78
|
+
const core = new WhatItBrokeCore();
|
|
79
|
+
const adapter = new ReactAdapter(core);
|
|
80
|
+
|
|
81
|
+
// Analyze React error with componentStack:
|
|
82
|
+
const report = await adapter.handleReactError(error, {
|
|
83
|
+
componentStack: errorInfo.componentStack
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
console.log(report.context.executionPath);
|
|
87
|
+
// ['App', 'Dashboard', 'UserProfile']
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Zero-Bloat Guarantee
|
|
93
|
+
`@whatitbroke/react` contains **zero Vue, Angular, or backend Node.js code**. It adds less than 8 kB to your frontend bundle and has `react` as an optional `peerDependency`.
|
|
94
|
+
|
|
95
|
+
## License
|
|
96
|
+
|
|
97
|
+
MIT © [WhatItBroke Team](https://github.com/jins-coder/whatItbroke)
|
package/package.json
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@whatitbroke/react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "React adapter, Error Boundary, hook rule analyzer, and component tree inspector for WhatItBroke",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
8
|
"files": [
|
|
9
|
-
"dist"
|
|
9
|
+
"dist",
|
|
10
|
+
"README.md",
|
|
11
|
+
"LICENSE"
|
|
10
12
|
],
|
|
11
13
|
"exports": {
|
|
12
14
|
".": {
|
|
@@ -23,8 +25,8 @@
|
|
|
23
25
|
"access": "public"
|
|
24
26
|
},
|
|
25
27
|
"dependencies": {
|
|
26
|
-
"@whatitbroke/shared": "1.0.
|
|
27
|
-
"@whatitbroke/core": "1.0.
|
|
28
|
+
"@whatitbroke/shared": "^1.0.1",
|
|
29
|
+
"@whatitbroke/core": "^1.0.1"
|
|
28
30
|
},
|
|
29
31
|
"peerDependencies": {
|
|
30
32
|
"react": ">=18.0.0"
|
|
@@ -37,7 +39,13 @@
|
|
|
37
39
|
"devDependencies": {
|
|
38
40
|
"@types/react": "^19.0.10"
|
|
39
41
|
},
|
|
40
|
-
"keywords": [
|
|
42
|
+
"keywords": [
|
|
43
|
+
"debugger",
|
|
44
|
+
"react",
|
|
45
|
+
"error-boundary",
|
|
46
|
+
"hooks",
|
|
47
|
+
"root-cause"
|
|
48
|
+
],
|
|
41
49
|
"author": "WhatItBroke Team",
|
|
42
50
|
"license": "MIT",
|
|
43
51
|
"engines": {
|