Answers for "how to change favicon react"

15

how to add favicon in html

<link rel="shortcut icon" type="image/png" href="Link to the image"/>
Posted by: Guest on February-23-2020
3

change title react

import React from 'react'
import ReactDOM from 'react-dom'


class Doc extends React.Component{
  componentDidMount(){
    document.title = "dfsdfsdfsd"
  }

  render(){
    return(
      <b> test </b>
    )
  }
}

ReactDOM.render(
  <Doc />,
  document.getElementById('container')
);
Posted by: Guest on May-15-2020
0

how to change favicon dynamic in react js

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;
Posted by: Guest on August-25-2021
-1

how to remove react icon from tab

<link rel="shortcut icon" href="/a.png" /> which should be not present by the way or try deleting the favicon
Posted by: Guest on November-06-2020

Browse Popular Code Answers by Language