How to update meta tags in React.js?

后端 未结 9 884
清酒与你
清酒与你 2020-12-28 12:05

I was working on a single page application in react.js, so what is the best way to update meta tags on page transitions or browser back/forward?

9条回答
  •  失恋的感觉
    2020-12-28 12:37

    Firstly if you don't need dynamic data you can just edit public/index.html.

    For dynamic data the React team recommends to either use react-helmet

    import React from "react";
    import { Helmet } from "react-helmet";
    
    class Application extends React.Component {
      render () {
        return (
            
    React app ...
    ); } };

    Or using placeholders and replacing them server-side:

    
      
        
        
      
    
    

提交回复
热议问题