📜  更改组件的一部分的路线 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:01.708000             🧑  作者: Mango

代码示例1
 (
    
  )}
/>

 (
    
  )}
/>


//Page Component
import React from "react"

/* 
 * Component which serves the purpose of a "root route component". 
 */
class Page extends React.Component {
  /**
   * Here, we define a react lifecycle method that gets executed each time 
   * our component is mounted to the DOM, which is exactly what we want in this case
   */
  componentDidMount() {
    document.title = this.props.title
  }

  /**
   * Here, we use a component prop to render 
   * a component, as specified in route configuration
   */
  render() {
    const PageComponent = this.props.component

    return (
      
    )
  }
}

export default Page