Coder Social home page Coder Social logo

Duplicate Title tags about react-head HOT 18 CLOSED

tizmagik avatar tizmagik commented on September 24, 2024
Duplicate Title tags

from react-head.

Comments (18)

tizmagik avatar tizmagik commented on September 24, 2024

Cascading title tag support was added in #37 and will be published as part of an upcoming v3 -- you can play around with it now by installing the next tag, npm i react-head@next

from react-head.

tizmagik avatar tizmagik commented on September 24, 2024

Any feedback you have on this feature would be appreciated and super helpful right now, as we haven't yet cut an official v3 release 😁

from react-head.

klase avatar klase commented on September 24, 2024

Ah sure will have a look at v3 then :)

from react-head.

klase avatar klase commented on September 24, 2024

Btw, will cascading support be limited to just title tags? What about og:title, og:description etc?

from react-head.

TrySound avatar TrySound commented on September 24, 2024

Only title and meta are supported currently.

from react-head.

klase avatar klase commented on September 24, 2024

So I just tried the v3 branch, and on the server the headTags array contains only one title tag as expected. However, once rendered, the nested tag gets overwritten by the tag in the root component as soon as a client side update occurs.

Also, meta tags with the following structure doesn't cascade on server nor client:
<Meta property="og:description" content="Some Content" />

from react-head.

tizmagik avatar tizmagik commented on September 24, 2024

I think the next tag is an older build, I'll cut a new one with the latest on master (I think that will include the meta support).

from react-head.

klase avatar klase commented on September 24, 2024

Great thanks @tizmagik

from react-head.

tizmagik avatar tizmagik commented on September 24, 2024

Just published 3.0.0-1 (against @next tag). Give that a spin 😁

from react-head.

klase avatar klase commented on September 24, 2024

Yay works on the server now with the meta tags but still have the issue where it gets overwritten by the first occurring tag and title whenever client side rendering/updating kicks in.

I also get an error when navigating away from any page with nested titles or tags in its component tree:
this.headTags.removeClientTag is not a function at HeadTag.componentWillUnmount

from react-head.

tizmagik avatar tizmagik commented on September 24, 2024

Thanks for the bug report @klase ! -- cc @TrySound

from react-head.

TrySound avatar TrySound commented on September 24, 2024

@klase Do you have HeadProvider in your tree in client?

from react-head.

praxxis avatar praxxis commented on September 24, 2024

I'm seeing this too on 3.0.0-1, client side only, with a HeadProvider. A title tag is defined in our index.html, and it's not being overwritten by the Title react-head tag (a second title tag is inserted in head by react-head, but it's ignored by the browser). react-helmet doesn't have the same issue, it seems to replace the existing title.

from react-head.

klase avatar klase commented on September 24, 2024

ahh nope 🤦‍♂️ thanks @TrySound. Maybe it can be added to the Client Setup section of the readme to make it clearer.

Unrelated: In the readme you're using renderToString to render the headTags array. Any reason why you're not using renderToStaticMarkup instead to avoid having data-reactroot attributes on all the tags?

from react-head.

TrySound avatar TrySound commented on September 24, 2024

@praxxis We are doing "rehydration" only for tags with data-rh attributes. Removing another stuff won't affect SSR and may break something. It's probably better to not have title tag in your source html.

from react-head.

TrySound avatar TrySound commented on September 24, 2024

@klase Nope, could you open an issue about that?

from react-head.

klase avatar klase commented on September 24, 2024

@TrySound sure

from react-head.

klase avatar klase commented on September 24, 2024

Closing this as 3.0.0-1 resolved my initial issue.

from react-head.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.