Currently I build an SDK that renders a React component into a legacy site that uses mainly HTML, CSS and plain javascript + jquery.
I do something like this:
document.addEventListener('DOMContentLoaded', () => {
const wrapper = document.getElementById('wrapper');
const configuration = {...}
app.loadElement(configuration, wrapper);
})
And on the SDK part I defined a method named loadElement that's something like this:
function loadElement(configuration, wrapper) {
ReactDOM.render(React.createElement(Element, { ...props }), wrapper);
}
Any ideas if there are any ways that I can improve this approach? Are there any other libraries that does a better job for this particular use-case? Can I adopt next.js for this use case?