Error Handling
If cacheKey
is not added to the cacheKeys.js
file, is duplicated, or is not a string or an object with a prefix
attribute, the component will display an error component. This is handled by wrapping the component usage in an ErrorBoundaryWrapper
.
For the following examples, cacheKeys.js
would be defined like this:
// Example src/components/components/column-picker/cache/cacheKeys.js
const CACHE_KEYS = [
"column-picker-demo-key-duplicated", // Assume this one is duplicated
"column-picker-demo", // Assume this one is valid for other demos
"column-picker-demo-key-duplicated", // Assume this one is duplicated
];
export default CACHE_KEYS;
cacheKey
not added to cacheKeys.js
:
Error in column picker
Error: The cache key prefix "column-picker-demo-key-not-added" was not found. Please add it to CACHE_KEYS or use one of the existing keys: column-picker-demo, column-picker-demo-key-duplicated
cacheKey
duplicated:
Error in column picker
Error: The cache key prefix "column-picker-demo-key-duplicated" was found more than once in CACHE_KEYS. Please remove duplicates.
cacheKey
not a string or an object with a prefix
attribute:
Error in column picker
Error: Invalid cacheKey prop: Must be a non-empty string, or an object with a "prefix" string attribute.
Note : if any other error occures, the same error component will be displayed but with a different error message.