React Errors
Show errors on the top-right
Demo
http://xcatliu.com/react-errors/
Usage
Warning: This component will render exactly what messages in errors
, so you should change errors
whenever onErrorClose
triggered.
examples/simple-example/App.js
;; const styles = container: textAlign: 'center' button: marginTop: 100 ; { super; thisstate = errors: message: 'A object contains message' 'An Error Instance' ; thishandleErrorClose = thishandleErrorClose; thishandleAddAnError = thishandleAddAnError; } { const newErrors = thisstateerrors; newErrors; this; } { const newError = 'new Error' + Date; const newErrors = thisstateerrors; newErrors; this; } { return <div style=stylescontainer> <button onClick=thishandleAddAnError style=stylesbutton > Add an error </button> <Errors errors=thisstateerrors onErrorClose=thishandleErrorClose /> </div> ; } ;
Props
Props | Description | Required | Default |
---|---|---|---|
errors |
array of error, each error should be a instance of Error or an object which contains message |
Y | |
onErrorClose |
trigger when the close button is clicked, with a param which is the index of errors | Y |
Contributing
Build
npm run build
Deploy
npm version <patch|minor|major>git pushgit push --tagsnpm publish
Build Examples
npm run build:examples
Deploy Examples
npm run deploy:gh-pages