import React from "react";
function getFaviconEl() {
return document.getElementById("favicon");
}
function App() {
const handleGoogle = () => {
const favicon = getFaviconEl(); // Accessing favicon element
favicon.href = "https://www.google.com/favicon.ico"; };
const handleYoutube = () => {
const favicon = getFaviconEl();
favicon.href = " https://s.ytimg.com/yts/img/favicon-vfl8qSV2F.ico"; };
return (
<div className="App">
<h1>Dynamically changing favicon</h1>
<button onClick={handleGoogle}>Google</button> <button onClick={handleYoutube}>YouTube</button> </div>
);
}
export default App;