@evo/errcatch
Advanced tools
Comparing version 0.0.5 to 0.1.2
@@ -7,3 +7,3 @@ "use strict"; | ||
exports.setErrCatchLog = setErrCatchLog; | ||
exports.ErrCatch = void 0; | ||
exports.withErrCatch = exports.ErrCatch = void 0; | ||
@@ -121,2 +121,13 @@ var _react = _interopRequireDefault(require("react")); | ||
name: 'Component render error' | ||
}); | ||
}); | ||
var withErrCatch = function withErrCatch(Component, name) { | ||
return function (props) { | ||
var displayName = name || "ErrCatch".concat(Component.displayName); | ||
return _react.default.createElement(ErrCatch, { | ||
name: displayName | ||
}, _react.default.createElement(Component, props)); | ||
}; | ||
}; | ||
exports.withErrCatch = withErrCatch; |
{ | ||
"name": "@evo/errcatch", | ||
"version": "0.0.5", | ||
"version": "0.1.2", | ||
"description": "Catch react errors", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -21,3 +21,3 @@ # ErrCatch | ||
```jsx | ||
import { ErrCatch } from '@evo/errcatch' | ||
import { ErrCatch, withErrCatch } from '@evo/errcatch' | ||
@@ -32,2 +32,9 @@ const Component = () => ( | ||
); | ||
// or HOC | ||
const Component = withErrCatch(() => ( | ||
<div> | ||
<Component1/> | ||
</div> | ||
)); | ||
``` | ||
@@ -34,0 +41,0 @@ |
8181
112
69