in what folder i add js code with react code example
Example 1: how to import js via script in react
import { useEffect } from 'react';
const useScript = url => {
useEffect(() => {
const script = document.createElement('script');
script.src = url;
script.async = true;
document.body.appendChild(script);
return () => {
document.body.removeChild(script);
}
}, [url]);
};
export default useScript;
Example 2: different ways to write react file paths
Writing a path to a react file/project file
import something from '/thatThing'; this is the current tree
import something from '../thatThing';
import something from '../../thatThing';
dipending on your level of files you should be able to find a way to map through your project files with this tips.