v2.5.2
Giriş yap

React helmet UNSAFE_componentWillMount hatası

hakankorkz
171 defa görüntülendi

dostlar vite kullanarak react projesi açtım projem de React helmet paketini de kullanıyorum tittle seo işlevleri için aşağı da vermiş olduğum yapı da Head component oluşturdum ve yine aşağı da verediğim hata yazısını alıyorum

hata yazısı

(adsbygoogle = window.adsbygoogle || []).push({});

react_devtools_backend_compact.js:2367 Warning: Using UNSAFE_componentWillMount in strict mode is not recommended and may indicate bugs in your code. See https://reactjs.org/link/unsafe-component-lifecycles for details.

  • Move code with side effects to componentDidMount, and set initial state in the constructor.

Please update the following components: SideEffect(NullComponent2)

kod yapısı

(adsbygoogle = window.adsbygoogle || []).push({});

import React from "react";
import { Helmet } from "react-helmet";

class Head extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      title: "React compound component",
      canonical: "http://localhost:5173",
      favicon: "/favicon-light.png",
    };
  }

  render() {
    return (
      <Helmet>
        <meta charSet="utf-8" />
        <title>{this.state.title}</title>
        <link rel="canonical" href={this.state.canonical} />
        <link rel="icon" type="image/png" href={this.state.favicon} />
      </Helmet>
    );
  }
}

export default Head;



Cevap yaz
Cevaplar (0)
Henüz kimse cevap yazmadı. İlk cevap yazan sen ol!