How to obtain the state? of sub-components by react high-order components

http://www.css88.com/react/do.

after reading the documents on the official website, you probably know how the high-level components are encapsulated. Probably know how to encapsulate high-level components.

how do the current requirements obtain the state? of WrappedPage

(we are a mixed developer and need to update header and the icon in the upper right corner! You want to deal with header and upper-right functions in a uniform place; instead of adding duplicate code on every page.)

//basic
import React from "react";
import PropTypes from "prop-types";


//modules
import up from "../modules/cup";

//WrappedPage jsx
export default function mixinsPage(WrappedPage) {
  // 
  return class Page extends React.Component {
    constructor(props) {
      super(props);
    }

    componentWillMount() {
      console.log(WrappedPage);
       //
       up.plugins.setRightButton();
    }

    componentDidMount() {
        console.log(`created=>${this.state.badTitle}`);
        //title
        document.title = this.state.badTitle;
        up.plugins.setPageTitle(this.state.badTitle || " ");//ios  ""  
    }

    render() {
      // 
      // props
      return <WrappedPage {...this.props} />;
    }
  }
}

in reverse inheritance mode: state can be manipulated but WrappedPage"s componentWillMount and componentWillMount will not be executed.

export default function mixinsPage(WrappedPage) {
  // 
  return class Page extends WrappedPage {
    constructor(props) {
      super(props);
    }

    componentWillMount() {
      //
       up.plugins.setRightButton();
    }

    componentDidMount() {
   
       //title
       document.title = this.state.badTitle;
       up.plugins.setPageTitle(this.state.badTitle || " ");//ios  ""  
    }

    shouldComponentUpdate(nextProps, nextState) {
      console.log(nextState);
    }

    render() {
      // 
      // props
      // return <WrappedPage {...this.props} />;
      //  :state
      return super.render()
    }

  }
}

previous unified processing logic of vueJs!

//vueJs mixins 
beforeCreate() {
    //
    plugins.setRightButton();
  },
  created() {
    // log.clearLogs();

    console.log(`created=>${this.badTitle}`);
    //title
    document.title = this.badTitle;
    plugins.setPageTitle(this.badTitle || " ");//ios  ""  
  },
Mar.20,2021

consider ref, this.refs.wrappedPage.state. This is WrappedPage's state

.
  

the wrapped component and the component passed in for processing are not the same component. State is the component itself, and props is mobile. Back to the question, you can map state to props, just like connect does

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e54139-4527b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e54139-4527b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?