Skip to content

Commit

Permalink
0.0.1-beta.16 added erroe boundary atom
Browse files Browse the repository at this point in the history
  • Loading branch information
jagankumar-egov committed May 5, 2024
1 parent 56b4181 commit b269457
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 7 deletions.
2 changes: 1 addition & 1 deletion react/example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"build": "webpack --mode production"
},
"dependencies": {
"@egovernments/digit-ui-components": "0.0.1-beta.15",
"@egovernments/digit-ui-components": "0.0.1-beta.16",
"@egovernments/digit-ui-libraries": "1.8.2-beta.1",
"@egovernments/digit-ui-module-common": "1.7.10",
"@egovernments/digit-ui-module-core": "1.8.1-beta.6",
Expand Down
2 changes: 1 addition & 1 deletion react/modules/Project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"dependencies": {
"@egovernments/digit-ui-react-components": "1.8.1-beta.4",
"@egovernments/digit-ui-components": "0.0.1-beta.15",
"@egovernments/digit-ui-components": "0.0.1-beta.16",
"lodash": "^4.17.21",
"react": "17.0.2",
"react-date-range": "^1.4.0",
Expand Down
2 changes: 1 addition & 1 deletion react/modules/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"prepublish": "yarn build"
},
"dependencies": {
"@egovernments/digit-ui-components": "0.0.1-beta.15",
"@egovernments/digit-ui-components": "0.0.1-beta.16",
"@egovernments/digit-ui-react-components": "1.8.1-beta.4",
"react": "17.0.2",
"react-dom": "17.0.2",
Expand Down
2 changes: 1 addition & 1 deletion react/modules/sample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"dependencies": {
"@egovernments/digit-ui-react-components": "1.8.1-beta.4",
"@egovernments/digit-ui-components": "0.0.1-beta.15",
"@egovernments/digit-ui-components": "0.0.1-beta.16",
"react": "17.0.2",
"react-date-range": "^1.4.0",
"react-dom": "17.0.2",
Expand Down
2 changes: 1 addition & 1 deletion react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"@egovernments/digit-ui-module-sample": "0.0.1",
"@egovernments/digit-ui-react-components": "1.7.10",
"@egovernments/digit-ui-svg-components": "1.0.4",
"@egovernments/digit-ui-components": "0.0.1-beta.15",
"@egovernments/digit-ui-components": "0.0.1-beta.16",
"babel-loader": "8.1.0",
"clean-webpack-plugin": "4.0.0",
"css-loader": "5.2.6",
Expand Down
1 change: 1 addition & 0 deletions react/ui-components/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ yarn storybook
# Changelog

```bash
0.0.1-beta.16 added erroe boundary atom
0.0.1-beta.15 added info varinat for toast
0.0.1-beta.14 updated dropdown options label to use optionsKey
0.0.1-beta.13 nested and tree dropdown varinat updated
Expand Down
2 changes: 1 addition & 1 deletion react/ui-components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@egovernments/digit-ui-components",
"version": "0.0.1-beta.15",
"version": "0.0.1-beta.16",
"license": "MIT",
"main": "dist/index.js",
"module": "dist/index.modern.js",
Expand Down
36 changes: 36 additions & 0 deletions react/ui-components/src/atoms/ErrorBoundary.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Toast } from '@egovernments/digit-ui-components';
import React, { Component } from 'react';

class ErrorBoundary extends Component {
state = {
hasError: false,
error: null,
errorInfo: null
};

componentDidCatch(error, errorInfo) {
// Log the error to an error reporting service
console.error('Error caught by ErrorBoundary:', error, errorInfo);
this.setState({
hasError: true,
error: error,
errorInfo: errorInfo
});
}

render() {
if (this?.state?.hasError) {
// Render fallback UI
return (
<div>
{this?.state?.error?.toString() && <Toast error={true } label={this?.props?.moduleName+" : "+this?.state?.error?.toString()?.slice(0,100)} />}
{this?.props?.children}
</div>
);
}
// Render children normally
return this?.props?.children;
}
}

export default ErrorBoundary;
2 changes: 2 additions & 0 deletions react/ui-components/src/atoms/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ import InfoButton from "./InfoButton";
import Uploader from "./Uploader";
import UploadPopup from "./UploadPopup";
import DocPreview from "./DocPreview";
import ErrorBoundary from "./ErrorBoundary";

import {
ErrorBoundary,
AnnouncementIcon,
Calender,
CitizenTruck,
Expand Down
4 changes: 3 additions & 1 deletion react/ui-components/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ import {
InfoButton,
Uploader,
UploadPopup,
DocPreview
DocPreview,
ErrorBoundary
} from "./atoms";

import {
Expand Down Expand Up @@ -462,4 +463,5 @@ export {
ArrowLeftWhite,
ArrowRightInbox,
SearchIconSvg,
ErrorBoundary
};

0 comments on commit b269457

Please sign in to comment.