0.2.2 • Published 7 years ago
twcm-error-modal v0.2.2
twcm-error-modal
Error module to be used for all TWC platforms.
Installation
yarn add twcm-error-modal
Example Usage
import * as React from 'react';
import ErrorModal from 'twcm-error-modal`
class TWCComponent extends React.Component<{}, { error: Error }> {
constructor() {
super();
this.state = { error: null };
this._closeError = this._closeError.bind(this);
}
public breakingCode(): JSX.Element {
const onError = (e: Error) => this._handleError(e);
willBreak()
.catch(onError);
}
public render(): JSX.Element {
<div>
{ this.breakingCode() }
<ErrorModal
isOpen={ !!this.state.error }
err={ this.state.error }
onClose={ this._clearError }
/>
</div>
}
private _emitError(error: Error): void {
this.setState({ error });
}
private _closeError(): void {
this.setState({ error: null });
}
}
API
customMsg: string - Optional message to display
isOpen: boolean - (required)
err: Error - Full error object to display.
onClose: () => any; - (required) Function to run on modal exit.
customMsg?: string; err?: Error; isOpen: boolean; onClose: () => void;
Testing
1) Add some tests in a *.spec.tsx
file
2) Run yarn build
Contributing
1) Make some changes
2) Update tag in package.json
3) Ask james for NPM login info if you don't have one.
4) Run npm publish
(CI doesn't deploy yet)
5) Commit & push code
0.2.2
7 years ago
0.2.1
7 years ago
0.2.0
7 years ago
0.1.6
7 years ago
0.1.5
7 years ago
0.1.4
7 years ago
0.1.3
7 years ago
0.1.2
7 years ago
0.1.1
7 years ago
0.1.0
7 years ago
0.0.10
7 years ago
0.0.9
7 years ago
0.0.8
7 years ago
0.0.7
7 years ago
0.0.6
7 years ago
0.0.5
7 years ago
0.0.4
7 years ago
0.0.3
7 years ago
0.0.2
7 years ago
0.0.1
7 years ago