I have a react app that gets hosted internally for each of its users. Once the app is deployed in tomcat, I would like the user to be able to insert a javascript file in the public folder to return html and custom data fetched from an API into a typycal 'div" with an id inside of a side Panel, and therefore make the application customizable.
That way, the user would be able to develop their own javascrpit file to customize what they can see in the side panel
So, I understand it's possible to simply use the following method to import the javascript file this way:
var customSidePanel = require('../../../public/plugins/customSidePanel');
<PanelPaper title={'Custom Properties'}>
<div id={"customSidePanel-div"}>
{customSidePanel() != null && customSidePanel()}
</div>
</PanelPaper>
and the very simple js file:
module.exports = function () {
return 'Soon to be more';
}
The user would then be able to update their own custom side panel plugin without redeploying the entire app.
Is there a more efficient way of doing this? A way that would let me use react and other dependencies that I am alkready using in my existing react project? Is there a library that would allow me to do this? Should I make a completely new react project as a base for the user to use for their custom side panel?
question from:
https://stackoverflow.com/questions/65944410/how-to-import-a-custom-react-component-from-the-public-folder-and-insert-it-in-a 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…