feat: export the Root app in decap-cms-app, and add a flag to disable rendering #7368
Description
It would be awesome if decap-cms-app
exposed the Root
component defined in decap-cms-core
, and introduced a flag to disable rendering the app by default.
Is your feature request related to a problem? Please describe.
Somewhat. Decap doesn't always play nicely when it is inside of another React rendering context. Instead of using react-dom
to directly render decap into a DOM node, it would be great to simply expose the component and let the hosting React app handle the rendering.
Describe the solution you'd like
import DecapCMS, { Root as CMSApp } from 'decap-cms-core';
function MyReactComponent() {
DecapCMS.init({ config, render: false });
DecapCMS.registerPreviewTemplate(...);
return (
<div>
<CMSApp/>
</div>
);
}
Describe alternatives you've considered
With a deeper refactor, it would probably be good to disable the auto-init stuff as well by default, which would give more control to the app.
The final solution could be entirely component based...
import { Root as CMSApp } from 'decap-cms-core';
function MyReactComponent() {
return (
<>
<CMSApp config={...}/>
</>
);
}