I want to open an html file which is in my local, in a new tab on button click in react component. I am trying to import the html file and then use window.open() method of javascript for this purpose. But for importing the html file I need html-loader plugin. But I get this when I try to install the plugin using npm – enter image description here
Is there any other way to open an html file in a new tab on button click in react js and if not, why is the html-loader plugin not getting installed?
2
Answers
This can be d one with Vanilla JavaScript, I don’t believe you should need the
html-loader
plugin:html-loader
is used to read HTML files in as strings (see the npm package page here). As for why your installation isn’t working, it appears that you are having issues with some other packages you have installed (ant-design icons, material UI, and react). Perhaps try removing all conflicting packages withnpm uninstall [package-name]
and then subsequently reinstalling the ones you need.If you use react-router-dom, you might find the following code helpful.