I'm sorry, maybe I wasn't clear: what I would like to do is render the content of another component (for example a component Test, located in test.js, and indipendent from Index) inside the div in index.html (or if possible, another html file called test.html).
Writing what you said in your reply, the result is the whole code inside test.js.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Great article!
What should I edit if I want to associate other URLs to other .js files? For example, localhost:3000/test would load a test.js component...
Thanks Andrea.
If you want to do exactly that (i.e. pointing /test to the test.js file),
in the file server/index.js, add:
Make sure the Express JS version you are using (in package.json), is 4.8.0 or higher. Or else,
sendFile
wont be supported.If you need that because you need the .js files for your code and dont need to expose it publically, I would recommend to let webpack take care of it.
I'm sorry, maybe I wasn't clear: what I would like to do is render the content of another component (for example a component Test, located in test.js, and indipendent from Index) inside the div in index.html (or if possible, another html file called test.html).
Writing what you said in your reply, the result is the whole code inside test.js.