- Avoid accessing value from objects directly with more than 2 levels.
- Defaulting values will results in better error handling.
// Currently
<p>{data.schema.value}</p>
// if schema is undefined, entire UI will not show up.
// Proposed
<p>{data?.schema?.value | ''}</p>
// or
<p>{data?.schema?.value | 'Invalid Data!'}</p>
// safely renders the UI, and if there is a data error user still be able to revert those changes if possible possible.
// lodash also has some better way to acces this, when there is a complex path.
- Now, even a small module has an error, entire application will not show up.
- Now, if such errors occured, user might have to clear the data from pg or to wait for the update.
- Better error message can be shown only at the place of error. all other modules remains functioning.
- We may have to handle analytics by writing extra code. error boundary will not trigger here at all.