react-component-boundary 1.0.0 → 1.0.2
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/README.md +54 -0
- package/package.json +3 -2
package/README.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# react-component-boundary
|
|
2
|
+
|
|
3
|
+
A lightweight, reusable Error Boundary for React components that follows clean component design principles.
|
|
4
|
+
|
|
5
|
+
# Why this package?
|
|
6
|
+
|
|
7
|
+
React Error Boundaries often become:
|
|
8
|
+
|
|
9
|
+
- tightly coupled
|
|
10
|
+
- hard to reuse
|
|
11
|
+
- mixed with UI logic
|
|
12
|
+
|
|
13
|
+
This package keeps it simple and flexible:
|
|
14
|
+
|
|
15
|
+
- Parent owns state
|
|
16
|
+
- Child only renders
|
|
17
|
+
- Error UI is fully customizable
|
|
18
|
+
|
|
19
|
+
Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install react-component-boundary
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
# Basic Usage
|
|
26
|
+
|
|
27
|
+
```jsx
|
|
28
|
+
import { ComponentBoundary } from "react-component-boundary";
|
|
29
|
+
|
|
30
|
+
<ComponentBoundary customErrorMessage="Something went wrong">
|
|
31
|
+
<YourComponent />
|
|
32
|
+
</ComponentBoundary>;
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
# Custom Error UI
|
|
36
|
+
|
|
37
|
+
```jsx
|
|
38
|
+
<ComponentBoundary fallback={<div>Custom Error UI</div>}>
|
|
39
|
+
<YourComponent />
|
|
40
|
+
</ComponentBoundary>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
# Props API
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
interface ComponentBoundaryProps {
|
|
47
|
+
children: React.ReactNode;
|
|
48
|
+
customErrorMessage?: string;
|
|
49
|
+
className?: string;
|
|
50
|
+
fallback?: React.ReactNode;
|
|
51
|
+
onError?: (hasError: boolean) => void;
|
|
52
|
+
resetKey?: number;
|
|
53
|
+
}
|
|
54
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-component-boundary",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"access": "public",
|
|
5
5
|
"description": "A reusable React Error Boundary",
|
|
6
6
|
"keywords": [
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
"module": "dist/index.js",
|
|
15
15
|
"types": "dist/index.d.ts",
|
|
16
16
|
"files": [
|
|
17
|
-
"dist"
|
|
17
|
+
"dist",
|
|
18
|
+
"README.md"
|
|
18
19
|
],
|
|
19
20
|
"scripts": {
|
|
20
21
|
"build": "tsup src/index.ts --format esm,cjs --dts",
|