I have recently switched to React inorder to achieve single page application
Previously I had 8 html files and 8 js files which were linked by script tag
<script src="pathHere"> </script>
Now as I switched to React. Now the html pages are replaced by components with extension .js
How can I link some components(which have html content) with js (which contain js in jquery format) I tried to add component of js file in my jsx
import FirstJsFile from "../ApiCalls/FirstJsFile";
const Display = () =>{
return (
<div>
// jsx written here
<FistJsFile/> // This is the js file which conatins js in form of jquery
</div>
)
}
export default Display;
Then the js file contains this
const FristJsFile = () =>{
return (
<>{
$(function(){
console.log("Jquery getting loaded")
}
</>
)
}
export default FirstJsFile
<script>tags to that page. However, you probably shouldn't be mixing React and jQuery. Not unless you really know what you're doing. If you're just throwing together plugins for functionality, it's probably going to fail in a variety of ways as both jQuery and React do very different things with the DOM.