aem-react-editable-components
aem-react-editable-components copied to clipboard
fix(Container): Fix unmapped components silently do nothing
By doing console.warn when a child has a cqType not mapped to a component.
Description
console.warn when componentMapping.get(cqType here) finds no component mapped to that cqType.
Related Issue
https://github.com/adobe/aem-react-editable-components/issues/87
Motivation and Context
Thus helping developers to analyze scenarios where a component is not rendered.
The provided message is specific enough to help both when the cause of the issue is a missing/typo'ed MapTo and when is not (no rendering && not this message --> mapping is ok --> focus on other possible causes).
How Has This Been Tested?
Unit test is provided. Node.js version used was v14.17.3. No higher since that would bump the package-lock.json lockfileVersion.
Screenshots (if appropriate):
Resulting warning message in the console:

Types of changes
- [x] Bug fix (non-breaking change which fixes an issue)
Checklist:
- [x] I have signed the Adobe Open Source CLA.
- [x] My code follows the code style of this project.
- [x] My change requires a change to the documentation.
- [x] I have updated the documentation accordingly.
- [x] I have read the CONTRIBUTING document.
- [x] I have added tests to cover my changes.
- [x] All new and existing tests passed.
@samuelgomezvaltech - I was looking for something like this a while back and endedup writing a wrapper component that does the check for me. However I suggest a small change. Please add the warnings only when it is inEditor, this way there is no need for end users to be aware of this behavior. See if this makes sense. Thanks !