You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+20Lines changed: 20 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -74,3 +74,23 @@ The default `print` parameter value is `true`. It means that in this example the
74
74
75
75
### Print as a function
76
76
The `print` parameter can also be a function. Then the `props` and `context` are given to it (in this order), and it should return a boolean indicating wether or not the actual component should be displayed.
77
+
78
+
### Error handling
79
+
The `error` parameter allows to specify a prop that indicates wether or not a placeholder error component should be displayed in replacement of the real component.
80
+
It's usefull when data that are required for the correct display of a component are missing.
81
+
82
+
Like for the `print` prop, `error` can be a `boolean`, a `string` (referencing a prop name), an array of `string` (an array of prop names) or a `function` (whose result will be converted to `boolean`).
83
+
84
+
```js
85
+
// default error component will be displayed if 'error' prop is truthy
86
+
exportdefaultloader()(MyComponent)
87
+
88
+
// default error component will be displayed
89
+
exportdefaultloader({ error:true })(MyComponent)
90
+
91
+
// default error component will be displayed if 'errorMessage' prop is truthy
function_classCallCheck(instance,Constructor){if(!(instanceinstanceofConstructor)){thrownewTypeError("Cannot call a class as a function");}}
22
+
23
+
function_possibleConstructorReturn(self,call){if(!self){thrownewReferenceError("this hasn't been initialised - super() hasn't been called");}returncall&&(typeofcall==="object"||typeofcall==="function") ? call : self;}
24
+
25
+
function_inherits(subClass,superClass){if(typeofsuperClass!=="function"&&superClass!==null){thrownewTypeError("Super expression must either be null or a function, not "+typeofsuperClass);}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor: {value: subClass,enumerable: false,writable: true,configurable: true}});if(superClass)Object.setPrototypeOf ? Object.setPrototypeOf(subClass,superClass) : subClass.__proto__=superClass;}
@@ -26,13 +24,7 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen
26
24
27
25
function_inherits(subClass,superClass){if(typeofsuperClass!=="function"&&superClass!==null){thrownewTypeError("Super expression must either be null or a function, not "+typeofsuperClass);}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor: {value: subClass,enumerable: false,writable: true,configurable: true}});if(superClass)Object.setPrototypeOf ? Object.setPrototypeOf(subClass,superClass) : subClass.__proto__=superClass;}
0 commit comments