I'm totally new to ReactJS and freshly completed my tutorial and now I'm working around with React. I started with just making a PHP file echo "Hello" and React.js fetching that response and displaying it on the website but it doesn't seem to work at all.
My PHP code:
<?PHP
echo "Hello!";
?>
My React.js code:
const [data, newData] = useState(null);
useEffect(() => {
fetch(//MY .php file link, NOT API just a php file echoing hello)
.then((response) => response.json())
.then(newData);
});
return (
<>
<div>
{ data }
</div>
</>
);